I'm looking to split an MPEG-2 source into sections that can then be rejoined. I have a reliable workflow for h.264 material that allows me to find the proper i-frames to make clean cuts. But with MPEG-2, I can't distinguish regular I-frames from GOP boundaries to make appropriate cuts. There's an I-frame about every 500ms, but they aren't all GOP borders.
I've tried different "smart cutters" like Solveig and VideoRedo, but I still don't get seamless rejoins with those smart cuts. I also tried VideoRedo's GOP cut option but when I eventually rejoin, there's a very noticable "repeat," as if the cut points overlap by about half a second. I think those options would work fine if I were trying to extract segments, but since I am cutting and rejoining, the cuts really need to be seamless.
I use FrameCounter with h.264 to find the appropriate I-frames. Is there something similar for MPEG-2 material? Any other ideas?
+ Reply to Thread
Results 1 to 11 of 11
How are you rejoning parts after? You can see frame types in VideoReDo (View/ Display On Screen Information) and in Avidemux (doesn't have smart cutting). MPEG-2 should be easier to cut than H.264 but you can still have issues if the GOP is open. In that case try to cut it so that the last frame of the scene 1 is a P frame and the first frame of Scene 2 is I frame. It's not guaranteed to work for every scene though... Then again VRD should be able to easily re-encode (smart render) few frames of each gop and make seamless cuts.
Open GOPs use the first frame of the next GOP instead of a final P frame. So to decode the final B frames you need to include the I frame of the next GOP. Making things even difficult those final B frames of the GOP are stored after the I frame of the next GOP.
So in looking at other documentation I see that you can have open and closed GOPs in the same video. For example, chapters must begin with a close GOP. Instead of just making my cuts as close to the desired sequence as possible, I will try and make my cuts around chapter boundaries to increase my likelihood of cutting on closed GOP boundaries.
I use SmartCutter for any type of video works like a hot knife on butter.
FFMpeg does a pretty good job with the recent versions of cutting frame accurate and making the first frame start at 0.00000 without encoding. You just have to be aware that it takes about 2 frames (depending on codec) to put the brakes on. This is why if you try to cut exactly on an I-Frame or 1 frame early, you next all the way to the next I or P frames. Many cutters do this without manual intervention. For this reason, I wrote a cutter that encodes just what is needed and copies the rest, being frame accurate .
[Attachment 50859 - Click to enlarge]
This is an example of cutting times 0 - 139. You need to get the times where you want to cut, (I assume you use something similar to FFProbe) either with FFProbe or outputting the times and frames as it plays.
[Attachment 50860 - Click to enlarge]
Then set your cut point 2 frames short. In the highlighted area it is a 'B' Frame 2 short of frame 3499, a 'P' Frame before The cut point intended and the cut will include this.
[Attachment 50861 - Click to enlarge]
[Attachment 50862 - Click to enlarge]
Then just use FFMpeg as :
ffmpeg -ss 0.000000 -i "C:\Users\Bud\Desktop\G50_25_Test_Pattern_w_sound.mp4" -t 139.880000 -c:v copy -c:a copy -y "C:\Users\Bud\Desktop\0_0_G50_25_Test_Pattern_w_sound.mp4"
Last edited by Budman1; 14th Nov 2019 at 02:52.
mkvmerge for cutting (except for these cases where I've tried smart encoders to help with the MPEG-2 stuff). Your program looks slick. I'll try ffmpeg with frame adjustments you recommended.