View Single Post
Old 20th January 2019, 22:21   #1  |  Link
Travillion
Registered User
 
Join Date: Aug 2018
Posts: 8
Cutting on IDR frames in mkvmerge

Hello all,

I thought this would probably go better in the editing sub-forum but couldn't find an appropriate category as it doesn't related to avisynth or NLE, etc. So I placed it here.....

I am trying to cut out sections from an h264 source. I understand I need to cut on the IDR frames so I extracted the raw file, ran it through FrameCounter to identify the IDR frames, and selected the appropriate frames. To test my identification of IDR frames, I cut each desired segment out as an individual file and checked playback. Each file played perfectly. To further test the cuts were appropriate, I combined them and they played seamlessly as a single file. All this was done in mkvmerge command line, so no re-encoding is occurring.

Now, I want to do the inverse. In other words, instead of keeping the sections as separate files, I want to discard those portions and leave the remainder of the film intact. But when I do this, using those same ranges, the film now has playback errors (a/v sync issues, black screen with ongoing audio, etc.). So, for whatever reason, I am extracting on IDRs, but I am not discarding on IDRs, if that makes sense.

Here are some concrete details:
Sections (note, each range below begins and ends on an IDR frame):
56075-56195
77926-77950
80223-80343

To extract the sections, I use: mkvmerge -o output.mkv --split parts-frames:56073-56193,77924-77948,80221-80341 input.mkv
(The frames referenced here are each -2 from the IDR frames identified above because mkvmerge begins counting frames at 1 and FrameCounter begins at 0, so I subtract 2 in order to be safe.)
As I said above, this works flawlessly. The individual files play great and they can be merged with no issues, because they are each an independent GOP.

To try and discard the sections, I use: mkvmerge -o output.mkv --split parts-frames:-56073,+56193-77924,+77948-80223,+80343- input.mkv
For whatever reason, the resulting output file is not cutting on the IDR frames and the playback is funky. I have tried adjusting those frame ranges a few, never going above the IDR # (e.g., 56071, 56072, 56074, but not 56075+), and it doesn't make any difference.

Any ideas?

Last edited by Travillion; 20th January 2019 at 22:37.
Travillion is offline   Reply With Quote