View Full Version : Splitting with mkvtoolnix
nekrovski
2nd January 2012, 00:16
[EDIT] Just noticed there's a big mkvtoolnix thread out there, please moderators forgive me if it's bad to open a new thread for this, I'll be greatful if you just merge my post there :)
Yo experts!
I have stumbled upon a slight problem when I'm splitting mkv files with mkvtoolnix. The problem is that, the splitting is not precise as I want it to be. For example let's say I have 1 hour video, I want to cut the part from 35:30 to 37:25 and the outcome is always either few/several seconds later than 35:30 and sooner/later than 37:25. I have noticed that this happens when the scene in the video is changed. I have read something about keyframes but... Is there a fix for this, or is it simply too complex for mkvtoolnix to split precise mkv files?
Oh I forgot, happy new year!
Inspector.Gadget
2nd January 2012, 00:51
Splitting on non-keyframes is a bad idea because you end up with orphan frames in every split output file but the first in time. This presents on playback as macroblocking or similar video corruption until the decoder reaches the next keyframe. Thus, mkvmerge is doing the most logical thing under the circumstances. In your x264 encodes, if you absolutely must have a keyframe at a particular frame, you can specify this by passing x264 a .qp text file to force creation of a keyframe there, with the result that intelligent tools like mkvmerge will split at that keyframe if you tell them to.
nekrovski
2nd January 2012, 00:59
Splitting on non-keyframes is a bad idea because you end up with orphan frames in every split output file but the first in time. This presents on playback as macroblocking or similar video corruption until the decoder reaches the next keyframe. Thus, mkvmerge is doing the most logical thing under the circumstances. In your x264 encodes, if you absolutely must have a keyframe at a particular frame, you can specify this by passing x264 a .qp text file to force creation of a keyframe there, with the result that intelligent tools like mkvmerge will split at that keyframe if you tell them to.
Thanks for your reply, however I don't quite get what you said :(
Can you tell me step by step how do I do that .qp text file thingy?
I'm not really experienced in these stuff.
Chumbo
2nd January 2012, 16:00
You need to take a look at frame-accurate editing software like VideoReDo (http://www.videoredo.com).
nekrovski
2nd January 2012, 16:34
No free alternatives?
profiler 2.0
2nd January 2012, 17:51
No free alternatives?
Hello, not now.
but does not mkv video redo input?
possibly changing the container.
Inspector.Gadget
2nd January 2012, 18:31
Thanks for your reply, however I don't quite get what you said :(
Can you tell me step by step how do I do that .qp text file thingy?
I'm not really experienced in these stuff.
When you have x264 all ready to encode (from an Avisynth script or some other input), add --qpfile somefile.txt to the command line, where somefile.txt is a list of frame numbers, frame types, and optionally a QP value (you can ignore this last one). So if you wanted to produce an encoded stream that mkvtoolnix would split exactly at frames 1000 and 2000, your somefile.txt would look like
1000 K
2000 K
Then, in MKVMerge, you would set the split points to be the timecodes corresponding as closely as possible to these frame numbers, and MKVMerge would automagically select these keyframes as the split points.
nekrovski
2nd January 2012, 19:50
When you have x264 all ready to encode (from an Avisynth script or some other input), add --qpfile somefile.txt to the command line, where somefile.txt is a list of frame numbers, frame types, and optionally a QP value (you can ignore this last one). So if you wanted to produce an encoded stream that mkvtoolnix would split exactly at frames 1000 and 2000, your somefile.txt would look like
1000 K
2000 K
Then, in MKVMerge, you would set the split points to be the timecodes corresponding as closely as possible to these frame numbers, and MKVMerge would automagically select these keyframes as the split points.
Wow, thanks a lot Inspector.Gadget, this worked!
I had to try some stuff first because I'm not used to command lines, but I did the job with megui. It's a bit more work but it gets the job done. Thanks again.
Chumbo
4th January 2012, 18:26
No free alternatives?
Unfortunately not. It sucks, I know. You can try tsmuxer which is a little better but still not frame-accurate. You can demux what you need and then remux all the segments with mkvmerge.
I've never used the qp method but it's good to know it's there as a freebie. :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.