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
  • Replace -t with -to
    – Marware
    Commented Mar 24, 2019 at 18:24
  • @Marware nope, that just chnages if the time is a duration or end time. Commented Mar 25, 2019 at 11:01
  • I think I found the answer here: superuser.com/questions/138331/using-ffmpeg-to-cut-up-video I need to put -ss in front of -i with some more time. ffmpeg -ss 00:08:00 -i Video.mp4 -ss 00:01:00 -t 00:01:00 -c copy VideoClip.mp4 Commented Mar 25, 2019 at 11:03

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 you have read our privacy policy.

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