I have a MKV video and I want to cut from seconds 3.3 to 22:07 minutes, but I can't cut at that start timing because there isn't a keyframe. How can I bypass that?

  • 3
    You can’t “bypass” it. If that was possible it would be the default option. If you use -codec copy, you must cut on key frames, otherwise re-encoding is required.
    – SlimSCSI
    Jul 5 '20 at 17:41
  • ok, thanks for your help
    – tommy
    Jul 5 '20 at 22:04

While in many cases it is impossible, there are cases where it may be theoretically possible. I will ignore here cases where no keyframes exist, since your question clearly stated that you are dealing with the codec with keyframe, but codecs differ in whether they allow keyframes in specific locations, or a keyframe may appear at any point.

If you have the latter, it would be possible to set up a case like the following:


Here the green frames are Key Frames, and the red is the new keyframe that will be created. You can see that most blocks can be copied as is, without reencoding, that is because every frame that follows the keyframe that can be just copied, can just be copied itself. We can also simply drop the unneeded frames from the last block without any issues (in many cases).

So what is happening with the red keyframe? It is generated from the information that come from the keyframe of the first block, plus all the changes that were applied by the frames following it up until the specific timestamp. This is 3.3 seconds in your example.

I will repeat myself once again, that in order for this to generate a playable file, you would need to be dealing with the codec which allows you to have as few frames between keyframes as you have left in the first block.

I am unaware of any tool which makes this approach easy, however.

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.