4

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?

3

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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