2

I have an MKV video, and want to cut the first 3 seconds. I tried with FFmpeg:

ffmpeg -i /input.mkv -ss 00:00:3.0 -c copy -t 00:09:58.0 output.mkv

But the result (when played in VLC) is that there are 5 seconds blank video with the original sound, and after that, the video shows.

I think it has something to do with a missing keyframe at the beginning. So I tried:

ffmpeg -i /input.mkv -ss 00:00:3.0 -c copy -t 00:09:58.0 -force_key_frames 00:00:00.000 output.mkv

But this has no effect - same result.

How can I cut a video properly so that it begins exactly where cut?

0

This is answered in FFmpeg's Seeking wiki page. The behavior is expected: If the time hits to a space between 2 key frames, it copies only audio up to the next keyframe and fills the video with black.

There are some methods to get also the beginning.

  • One is to overlay the copied part with few seconds of re-encoded original.
  • Or, simply, seek to a bit earlier frame.
  • Or, find the previous keyframe and clip from that.
  • Or, reencoding the whole clip.

It's a bit pity that FFmpeg (AFAIK) doesn't have a feature for this built in.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.