7

I use this to cut a part out of a MP4 file:

ffmpeg -i input.mp4 -vcodec copy -acodec copy -ss 00:36:18 -to 00:39:50 output.mp4

It works good but the video image is always freezed in the beginning for 1 second.

It doesn’t matter which video file I try and cut a part out of, it takes like 1 second before the video start.

Heres an example of what I am seeing.

3 Answers 3

5

The issue might be that the video is attempting to cut based solely on key frames and not in-between frames and your initial time of 00:36:18 is a few seconds ahead of a keyframe. The solution should be to use the -copyinkf option which is described in the manual as:

When doing stream copy, copy also non-key frames found at the beginning.

So your command which looks like this:

ffmpeg -i input.mp4 -vcodec copy -acodec copy -ss 00:36:18 -to 00:39:50 output.mp4

Would then need to be adjusted to look like this with -copyinkf mixed into it:

ffmpeg -i input.mp4 -vcodec copy -acodec copy -copyinkf -ss 00:36:18 -to 00:39:50 output.mp4
4

The timestamp you are copying from is between key frames, using -vcodec copy will always result in this behaviour if copying an inter frame codec and your input does not start on a key frame.

Your options are to either do a full encode (ie. no -vcodec copy) or to choose a different timestamp to seek to. You can find the location of all key frames using ffprobe eg.

ffprobe -select_streams v -show_frames -print_format csv -show_entries frame=key_frame,pkt_dts_time input.mp4  | grep "frame,1"

the third column contains the timestamps (in seconds) of all the key frames, you want the one closest to but not after your target timestamp.

0

I had this problem too, I have zero knowledge why this happened and how i fixed it. Just know that this code fixed it for me:

ffmpeg -ss 00:00:00 -to 00:00:10 -i input.mp4 -c:v copy -c:a copy output.mp4
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .