I have this WebM file that I need to split, but I'd like to do it without re-encoding. Putting it in an MKV container doesn't work, because the point where I need to split it is not a keyframe, so it doesn't work.

Is this possible? I'd really like to do it without re-encoding if possible, because I don't want to have to lose any quality.

  • 1
    If the point at which you wish to split it is not a keyframe, then no, this is not possible. All non-keyframes rely in part on the previous frame in the sequence (they essentially record changes to the previous image rather than a whole image -- there are b-frames that complicate this, but the same principle applies) and changing this to an I-frame (keyframe) involves re-encoding.
    – evilsoup
    Aug 29 '13 at 9:41
  • Damn. I assume there isn't any way to add a keyframe in or something, either... That's really annoying. Aug 29 '13 at 9:53
  • I think @evilsoup should post this as an answer. There is really no way to add keyframes later on. Depending on your use case though, there might be other options. What do you need to achieve exactly, Tamara?
    – slhck
    Aug 29 '13 at 10:19
  • Basically, I need to split the video because it's part one of a two part video I got from YouTube. The problem being, there's an outro at the end of the video, and I'd like to cut that off. I already know how to join the videos back together, that's really easy. Aug 29 '13 at 10:26

It's quite easy using the command avconv from the command line. You do not need to worry about splitting on a keyframe if, as the questioner later specified, you are cutting off an outro (the end of the video). Here's an example:

$ avconv -i videoandoutro.webm  -t 00:03:30  -codec: copy  videoonly.webm

That would take videoandoutro.webm and create a new file, videoonly.webm and truncate it after exactly 3 minutes and 30 seconds.

Cutting off an intro as well is actually not much harder, but doing that will run into keyframe issues.

$ avconv -ss 00:01:01 -i jossintro.webm  -t 00:00:30  -codec: copy oatybar.webm

The above will take a .webm file called "jossintro.webm" and cut a slice starting at around 1 minute, 1 second in. The output is put in "oatybar.webm", which is trimmed to (about) 30 seconds long. The result will actually be slightly longer since the start time will be rounded to the previous keyframe.

[Note that avconv is based on ffmpeg, and so that tool will likely also work, but I have only tested this with avconv.]

  • This is a great answer. I used it to break a video into a front and back half and remove some in the middle. Then I used mkvmerge to hook them up as I couldn't get avconv to concat, although I think it should have worked. Dec 12 '15 at 15:10

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.