VideoHelp Forum

Try DVDFab and download streaming video, copy, convert or make Blu-rays,DVDs! Download free trial !
+ Reply to Thread
Results 1 to 11 of 11
Thread
  1. Member
    Join Date
    Aug 2018
    Location
    Phoenix
    Search Comp PM
    Hi all,

    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?
    Quote Quote  
  2. 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.
    Quote Quote  
  3. Also Mpeg2cut2 and DgIndex. But open GOPs may continue to be a problem.
    Quote Quote  
  4. Member
    Join Date
    Aug 2018
    Location
    Phoenix
    Search Comp PM
    Originally Posted by badyu17 View Post
    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.
    I think part of the problem has been the frames I am cutting on. I was navigating to just I-frames and so it may be that VRD is making both cuts on the I-frames, not starting on the I-frame and ending on the P frame
    Quote Quote  
  5. 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.
    Quote Quote  
  6. Member
    Join Date
    Aug 2018
    Location
    Phoenix
    Search Comp PM
    Originally Posted by jagabo View Post
    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.
    Wait what?! That sounds impossible to make clean cuts without including redundant frames. Are there no self-contained boundaries in open GOPs?
    Quote Quote  
  7. Member
    Join Date
    Aug 2018
    Location
    Phoenix
    Search Comp PM
    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.
    Quote Quote  
  8. Member dellsam34's Avatar
    Join Date
    Jan 2016
    Location
    Paris Ca, 92345 Mexico
    Search PM
    I use SmartCutter for any type of video works like a hot knife on butter.
    Quote Quote  
  9. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    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 .
    Image
    [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.

    Image
    [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.
    Image
    [Attachment 50861 - Click to enlarge]


    Image
    [Attachment 50862 - Click to enlarge]


    Then just use FFMpeg as :
    Code:
    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.
    Quote Quote  
  10. Member
    Join Date
    Aug 2018
    Location
    Phoenix
    Search Comp PM
    Originally Posted by dellsam34 View Post
    I use SmartCutter for any type of video works like a hot knife on butter.
    I'll check it out, thanks!
    Quote Quote  
  11. Member
    Join Date
    Aug 2018
    Location
    Phoenix
    Search Comp PM
    Originally Posted by Budman1 View Post
    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 .
    Image
    [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.

    Image
    [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.
    Image
    [Attachment 50861 - Click to enlarge]


    Image
    [Attachment 50862 - Click to enlarge]


    Then just use FFMpeg as :
    Code:
    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"
    I've never used ffmpeg to cut, all of my stuff is in mkv container so I usually use 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.
    Quote Quote  



Similar Threads