Need to cut MKV file into parts

Everything related to MakeMKV
Post Reply
Tango
Posts: 43
Joined: Fri Nov 05, 2021 6:20 am

Need to cut MKV file into parts

Post by Tango » Fri Nov 18, 2022 6:56 am

I have some MKV files that I've pulled off BDs. The problem I'm running into is I could not pull off single episodes by themselves. In several cases I have 2 episodes in one MKV. (Fortunately, this is only a problem on ONE BD out of 15 seasons!) I prefer to slice such a file right after I pull it off the BD (or DVD) and it's in MKV form, since I know that's about the best quality video I'm going to get for that video. Anything I do to convert or to modify, I know I'm almost always going to get a lossy format file, so even loading it in, slicing it, and saving the shorter parts, may run into some quality loss.

I'm using Avidemux for slicing. I've tried loading both files I need to slice and I get a warning that there is no timestamp on the B Frames. (I know what I, P, and B framers are - in general, at least.) The program wants to add timestamps. I tried this on one file and a video over 80 minutes long ended up at 6 minutes long. So I tried again, without the program generating timestamps for the B frames. It played the video okay, without stalling, but once I tried to save sliced parts of the video, I found that the frames would often freeze in the output files, when played on VLC. The audio would keep going but the video would freeze every few seconds.

I've considered several options:

1) Find another program that will do this. Not sure what to try.
2) Use VLC - the problem is VLC needs to run for the full length of the edit - and I don't want to be doing other work that might mess with the video timing while that plays (and then I have to be sure to be back at the computer at the right time to stop it).
3) I could use Handbrake to convert it to the final format I'll be using (mpg) for storage, but that leads to the concern I mentioned above - will I lose more data slicing it up as an mpg than as MKV, taking the files fresh off the BD.
4) Can I use Handbrake (which has copied and converted similar files successfully in the past) to go from MKV to a lossless format and edit in there?
5) Am I worrying too much about losing picture quality by converting to MPG then slicing it up?

dcoke22
Posts: 3072
Joined: Wed Jul 22, 2020 11:25 pm

Re: Need to cut MKV file into parts

Post by dcoke22 » Fri Nov 18, 2022 7:32 am

MKVToolNix is probably the right set of tools to use.

I don't have any experience with Avidemux, but after a cursory glance, it looks like a non-linear editor, which is great when you're editing a video together from a bunch of clips, but it isn't the best tool for chunking up a .mkv file.

Tango
Posts: 43
Joined: Fri Nov 05, 2021 6:20 am

Re: Need to cut MKV file into parts

Post by Tango » Fri Nov 18, 2022 7:41 am

Actually, about all you can do with Avidemux is load a file and pick start and end points and save the segment between them. Then repeat for the next segment. I haven't tried it, but I don't think it can even join to files together. It's a far cry from non-linear.

ArArdin
Posts: 196
Joined: Fri Nov 20, 2020 1:40 pm

Re: Need to cut MKV file into parts

Post by ArArdin » Fri Nov 18, 2022 11:35 am

Likely, dcoke22 suggests the best tool. Should it be of concern, MKVToolNix also perfectly cuts video parts with TrueHD Atmos.

Where there is a snag for joining cutted TrueHD-parts back together. Or, as you may put it, remove a segment. TrueHD (with or without Atmos) carries two types of audio-frames, where not every frame can be cut upon. Chances are high that audio can't be cut at the exact timepoints where you cut video. I doubt that avidemux can cope with this.
Tango wrote:
Fri Nov 18, 2022 7:41 am
Actually, about all you can do with Avidemux is load a file and pick start and end points and save the segment between them.
Opposite from saving, you can also delete an A-B button selection.

Tango
Posts: 43
Joined: Fri Nov 05, 2021 6:20 am

Re: Need to cut MKV file into parts

Post by Tango » Sun Nov 20, 2022 4:06 am

dcoke22 wrote:
Fri Nov 18, 2022 7:32 am
MKVToolNix is probably the right set of tools to use.
Apologies. I thought I had noted I'd have to wait to look into MKVToolNix until I had a bit of time. I'm on a Mac. I use Linux a lot, but for this, it's on the Mac and those are big files to copy back and forth on my LAN. Fortunately they do have binaries for Mac. (I see they have Homebrew, but my Homebrew install went bad years ago and I asked for help with it on the forum, but didn't get enough to actually fix it.)
ArArdin wrote:
Fri Nov 18, 2022 11:35 am
Likely, dcoke22 suggests the best tool. Should it be of concern, MKVToolNix also perfectly cuts video parts with TrueHD Atmos.
I'm a bit confused at this point. I've installed MKVToolNix and it doesn't look like anything I can do in the GUI lets me save only sections of the video. I thought mkvextract might do it - but then realized it seems to only extract the metadata, not the actual video. I'm assuming I'm missing something with it?

Tango
Posts: 43
Joined: Fri Nov 05, 2021 6:20 am

Re: Need to cut MKV file into parts

Post by Tango » Sun Nov 20, 2022 4:29 am

Okay, got it. Use multiplexer. With all the functions treated as separate things in the GUI, I wasn't following. I'm kind of burned out lately and feel like I'm thinking through a fog - not moving too quickly these days.

dcoke22
Posts: 3072
Joined: Wed Jul 22, 2020 11:25 pm

Re: Need to cut MKV file into parts

Post by dcoke22 » Sun Nov 20, 2022 8:04 am

Hopefully there are chapter markers (and key frames) that line up with the division between the two episodes. The internet is full of examples. Here's one such example: https://superuser.com/questions/795373/ ... n-chapters

That's a bummer about your Homebrew install. Maybe it would be easiest to remove it all and install it again?
https://stackoverflow.com/questions/232 ... l-homebrew
https://github.com/homebrew/install#uninstall-homebrew

Tango
Posts: 43
Joined: Fri Nov 05, 2021 6:20 am

Re: Need to cut MKV file into parts

Post by Tango » Sun Nov 20, 2022 11:14 pm

dcoke22 wrote:
Sun Nov 20, 2022 8:04 am
Hopefully there are chapter markers (and key frames) that line up with the division between the two episodes. The internet is full of examples. Here's one such example: https://superuser.com/questions/795373/ ... n-chapters
I tried it - sorry, slow at responding and doing things these days. I had a mild case of Covid, but the recovery has been worse than the bug - I'm exhausted and think slowly right now.

I did get it to work by specifying the chapter to break before. It worked on all the files I was dealing with, so I'm happy. Got the immediate problem fixed AND found out about a new tool that I will, at times, find quite useful!
dcoke22 wrote:
Sun Nov 20, 2022 8:04 am
That's a bummer about your Homebrew install. Maybe it would be easiest to remove it all and install it again?
I've been considering that. The one issue is I can't remember what I've installed with Homebrew. I think I'm still using Fuse OS or something like that to read Linux devices on my Mac. I just haven't had time (and it hasn't been an immediate issue) to go to the forum and ask how to get a list of installed packages if the brew commands aren't working. (I figure there's gotta be a file with a list of installed packages somewhere!) When I get time to do that, I figured I'd make my list of installed packages, uninstall the whole thing, and start fresh.

Power-Read™
Posts: 8
Joined: Thu Dec 01, 2022 9:32 am

Re: Need to cut MKV file into parts

Post by Power-Read™ » Thu Dec 01, 2022 10:54 am

I find using the cli better as you "set" exactly what you need

Here are my notes from using MKV Merge (from MKVToolNix) that may help you cut/split parts of your mkv file ...
mkvmerge -i Yes,-Prime-Minister-5.mkv

mkvmerge -v --split parts:-00:02:29,00:00:31- Yes,-Prime-Minister-5.mkv
mkvmerge -v -o output.mkv --title title --split parts:-00:02:29,00:00:31-

mkvmerge -v --split size:700m
mkvmerge -v --split size:3.9



mkvmerge --split 1G --compression 0:none --compression 1:none --clusters-in-meta-seek -o "output.mkv" "input.mkv"

Post Reply