View Full Version : mkvmerge split an mkv into two parts at duration or timecode
loninappleton
28th May 2016, 22:57
I have used mkvmerge previously. But even with the manual-- and I have asked this before as well- I can never get the format straight to simply load the mkv and split it without the error box popping up constantly.
From 00:00:00 to 01:14:00 in HH MM SS is the goal as an example for the first segment. Save that and then do the second. Since I want to change the time slightly in the second segment for a fade to black which occurs in the content so a separate operation for part two is needed.
If possible give all the steps or direct to an uncomplicated sample. I have the bunkus guide but it is not clear to me as a casual user. The problem usually is all the if, thens which just confuse me.
hello_hello
29th May 2016, 06:17
If you just want to split the MKV into two parts, select "split after duration" as the splitting method and type 01:14:00 in the field below. Set the maximum number of files to 2. That'll output two files such as video-001.mkv and video-002.mkv. The split will happen at the first keyframe after 01:14:00, so if the file is split a little later than you'd prefer, try something like 01:13:59 instead.
Or you could use split "by parts based on timecodes" instead to specify just the sections you want. If you wanted just the first minute, you'd specify this:
00:00:00-00:01:00
If you wanted a segment one minute long from the beginning, and another segment one minute long starting at the five minute mark in the video, it'd be this:
00:00:00-00:01:00,00:05:00-00:06:00
MKVMergeGUI doesn't seem to like it if you use spaces between the timecodes.
loninappleton
29th May 2016, 06:52
you get around. :-)
I didn't want to start anymore difficulties with the usual bunch.
Yes, thank you. I think that will get me going again. Reading the how-tos and manuals on this they throw in word phrases like _until_ as an instruction which made no sense. I have been away from this again for a while and don't retain that much. Learning curve all over again.
The content I had been working on took quite a while.
Glad I have not got too many feathers ruffled.
And I wondered: Would it just destroy bunkus to put a tool tip pop up with the error message? Instead of " buzz, wrong, try again." Which is what happens.
hello_hello
29th May 2016, 11:05
Which version of MKVToolNix are you using? The current GUI provides a fair bit of detail under the Job Output window when there's errors.
For instance if you use split "by parts based on timecodes" and only enter a single timecode (ie 00:05:30), and not start and end timecodes (ie 00:05:30-00:06:45), the error message gives you a fair idea what's wrong.
--- Errors emitted by job 'merging to file "video.mkv" in directory "D:/"' started on 2016-05-29 19:59:26 ---
Invalid start/end specification for '--split' in '--split parts:00:05:30' (curent part: 00:05:30).
loninappleton
29th May 2016, 19:35
Which version of MKVToolNix are you using? The current GUI provides a fair bit of detail under the Job Output window when there's errors.
For instance if you use split "by parts based on timecodes" and only enter a single timecode (ie 00:05:30), and not start and end timecodes (ie 00:05:30-00:06:45), the error message gives you a fair idea what's wrong.
--- Errors emitted by job 'merging to file "video.mkv" in directory "D:/"' started on 2016-05-29 19:59:26 ---
Invalid start/end specification for '--split' in '--split parts:00:05:30' (current part: 00:05:30).
My Toolnix version is 8.8.0
Current version would be 9.2.0
The changelog looks long. I could go ahead and do the upgrade.
loninappleton
29th May 2016, 21:21
The story so far is I had version 8.8.0.
Getting 9.2.0 I had an an error installing Toolnix x64.
It failed at line Extract: mkvpropedit.exe
As an alternative I d/l'ed the current version 9.2.0 x 32 and that went in.
From there I was unable to find a replacement mkvmerge or run the old mkvmerge. At this point I am stuck without retrieving what I have in backup. mkvmerge is nowhere to be found that I can see including the very well kept up archive at videohelp.
Alternatively I can try to load the merge option in Toolnix and see if the screens etc. look familiar.
hello_hello
30th May 2016, 10:12
I'm not sure I'm understanding your problem exactly, but the exe for the old GUI was "mmg.exe".
For version 9.2.0 there is no MKVMergeGUI as such. The new GUI is MKVToolNixGUI (mkvtoolnix-gui.exe).
The exe running the new GUI might have been called something else originally, I can't remember, but I don't think there's ever been a download called "MKVMerge". As far as I know you've always had to download and install MKVToolNix and MKVMergeGUI was a component.
I don't use the installers so I don't know if they'd remove the old GUI when you upgrade, and if they do remove it, which MKVToolNix version would have been the first to do so. Maybe version 8.8.0 didn't remove the old GUI but now you've installed a version that does? I don't know.... that's just a guess.... as I use the portable MKVToolNix, so I just unzip any new version to it's own folder and run it. I don't know what the installers do.
loninappleton
30th May 2016, 18:21
ok.
There have been changes that account for the difficulty then. My last version was 8.8.0.
I will load and work with the new Toolnix and see what I get with the Merge tab.
Just now I'm not active with that job. Will report back with any success and mark the thread closed at that time.
loninappleton
31st May 2016, 21:27
Progress.
I am using Toolnix and was able to drag and drop an input file to the Mergeption, give it a simple time duration and _then_ select only 2 pieces as directed by this thread.
It was just a sample but went in ok.
The actual job may need some fine tuning on time. I recall that after HH:MM:SS the separator changes to a period and four digits in the Merge screen. Does the program respond to 2 digits for example in that ms category?
Also why did I have to go out to google and give a search to find my topic here? Elsewhere
the forum software can show "my posts" as an example. If it is available on Doom 9 I can't find it.
loninappleton
31st May 2016, 23:09
In the fine tuning part of this edit I think I ran into the keyframe issue.
Describing this may be familiar to the regulars:
When trying to set the duration for a fade out (or anywhere I suppose) at a time stamp of 1:14:28 as example, I see that the actual duration is longer at 1:14:35 in playback. What this does is go past the fade out (which is unfortunately really brief) and starts the next scene.
I am trying to correct for this.
Using DVD Shrink to get the initial time/duration in it's
Reauthor mode shows 1 hr 14 mins 26 secs and 10 frames.
This is the only program I've found to visually see what's happening at a given time. Virtual Dub key combinations hurt my hands.
What are some options in Toolnix? Would MKV Cleaver give better control over the key frame issue? I will experiment a bit more.
loninappleton
31st May 2016, 23:49
One more followup and I'll quit for today:
I had a save-able piece for this job by selecting the duration needed for the _part 2_ of the job. This gave the fade in to part 2 no problem.
But the part one duration to the fade out without sliding past it is still not fixed.
loninappleton
2nd June 2016, 21:20
Another angle on this dilemma might be a different form of editing.
I'll ask it this way: If I have a part in mkvmerge which looks good, is there a tool to simply delete 1 or at the most two seconds from the end? That would do it. That fade to black would then look alright.
loninappleton
4th June 2016, 22:27
Currently shopping around for mkv splitters. The Solveig program has a nice look, but frame accurate work requires the paid version or am I wrong.
AVIdemux is supposed to work with mkv as well. Any other suggestions welcome.
hello_hello
8th June 2016, 21:36
Sorry, I haven't been around for a while.
MKVToolNix will only cut on keyframes, so if it's not cutting where you want it to there's probably not a keyframe there. I usually specify the cut about a second before where I want it to be, because MKVMergeGUI will cut on the next keyframe after the specified duration.
For MKV containing h264 (probably applies to other video types) if you open the MKV with MPC-HC and use the left/right arrows in combination with the shift key, it'll jump between keyframes so you can check where they are.
Any program capable of "smart cutting" (cutting on non-keyframes) needs to be able to re-encode the section of video around the cut point. I've not used one myself so I don't know how successful they tend to be,. As a general rule I try to prepare the video for encoding so I'll not need to cut it after encoding, or I use Trim() in an Avisynth script to ensure only the section I want is re-encoded, so there's no need to split off a section later.
loninappleton
8th June 2016, 21:57
@hello_hello,
No need to apologize, you do more than enough. I am slow at doing this and always have been.
I will go over what you say and see if MKVcutter can make this one snip I need.
I recall having less problems working from the DVD in DVDShrink where the keyframe problem did not occur. These days I am using mkv container and h264 to get my file size down than what avi allows.
hello_hello
9th June 2016, 00:51
I'm pretty sure DVDShrink is still limited to keyframe cutting, but for mpeg2 video the keyframes are generally much closer together. For the x264 encoder, the "maximum" distance between keyframes is 10 seconds by default. That's the maximum, but the encoder is also good at putting them on the first frame of a scene, so often they're exactly where you need them for cutting. For fade-ins and fade-outs though, where there's no major change from one frame to the next (as happens on a scene change) that's not necessarily the case.
What program are you using for encoding these days? For the x264 encoder if you always use -stitchable in the command line (or have it checked in the program's encoder configuration) it'll ensure you can always join encoded video together (as long as it's the same resolution and the same encoder settings were used). That way, if you need to split where there's no keyframe you can split a bit earlier and then re-encode just a small section of video. As an example.....
Say a video is 1000 frames long. You encode it all but later realise you want to discard the last 50 frames. The problem is, in this example the last keyframe is frame 900 so you can't split on 950. That being the case, I'd split on 900 and then re-encode the next 50 frames by putting Trim() at the end of the script. Like this:
Trim(900,949)
When that's done you'd have a split section that's the first 900 frames and a re-encode of the next 50 frames you can append together with MKVToolNixGUI.
I generally go one step further and after splitting the first 900 frames I'd encode the rest using two scripts. One with this at the end as before:
Trim(900,949)
And another containing the last 50 frames I don't want.
Trim(950,999)
There's method to that madness though, because when you join the three sections together you know you now have a keyframe at frame 950 (where you wanted to split originally) so you can append the three sections, add the audio, then set MKVToolNix to split at frame 950 and remux. You can do it all in one step and that way MKVToolNixGUI can split the audio and video together at frame 950 for you.
loninappleton
9th June 2016, 03:45
You always come up with some bewts. ;-)
Trim is in Toolnix Gui then?
At this point I'll just go ahead and see if the MKVcutter works then come back to this.
I don't even know where the trim command is applied in your explanation above.
loninappleton
9th June 2016, 03:53
I forgot to answer your initial question.
For most encoding from DVD jobs I do these days, I'm using Vidcoder which is a shell of Handbrake. RandomEngy has done a redesign.
https://github.com/RandomEngy/VidCoder
He's added some things like a cpu throttle which can set encoding at 2/3 cpu speed allowing for some small tasks like web browsing as the job runs. There are other improvements but it follows the Handbrake engine with development.
hello_hello
10th June 2016, 19:25
Trim is an Avisynth function, so you won't be able to use it with Vidcoder, and I don't have Vidcoder installed, but Handbrake lets you set the start and end points for encoding by DVD title or chapter, or you can specify start and end points by time or frame number, so you should be able to specify the section of video you want to encode rather than have to split it after it's done. I'd imagine Vidcoder would have the same functionality.
loninappleton
10th June 2016, 22:15
Then I'd be going back to the original content on disk.
Have not used Handbrake in that way but I keep it updated along with Vidcoder.
Still slow at getting this right. It's just the way I have to approach it... when I'm ready.
loninappleton
10th June 2016, 23:00
Working from the disc in Handbrake, another angle on this could be to end of chapter (?) So do an encode from the original media to a chapter break before part 2.
But I have some progress. I have save it off to make sure but the MKVcutter did yield what appears to be a good break.
Lots of guesswork on a job like this. I still would like to try the Handbrake method. soon.
loninappleton
11th June 2016, 20:11
Two threads on the same topic of MKVcutter.
I wrote out how MKVcutter works for my own use and copied it in here from the other thread if anyone needs it.
MKVcutter has a minimal dialog with the user.
Before opening the program, create a designated temp folder
which the program will use to save your work. It can be named anything
you like.
Open program
Drag the content to the small upper box.
Mkvcutter analyses the content.
Then Your content is shown in a viewer.
Setting Start and Stop in the viewer is well laid out. Either time
or frame count can be visually inspected.
Set the first marker with Start Cut
Set the end marker with End Cut
Then
Lower right, select Add To Cut List
Then
select Commit To Cut list
A new screen opens for the final procedures.
At top right, click output file to name your job.
then Save
At Temp Folder, navigate to the folder you made described above in this exercise
I've written out the steps for myself but added it here since many
of the steps are laid out with backtracking necessary if you haven't
seen a guide for it.
Is there a way to get a log of the activity?
hello_hello
11th June 2016, 23:57
I've never used MKVCutter so I can't help with that one.
loninappleton
12th June 2016, 01:47
It seems to be settled off at this point.
I don't see a "marked solved" on here if there is one. If there is, someone say so and I'll complete it.
loninappleton
22nd June 2016, 21:49
Just a followup here on MKVcutter.
It hung up for me in processing my current 3Gb job and so I reverted to the MKVmerge option of MKVToolnix.
'Nix also loads a 3gb file a lot faster than MKVcutter. But as is shown above, MKVCutter will be a good addition to your toolbox to edit what cannot be done with Toolnix.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.