VideoHelp Forum
+ Reply to Thread
Results 1 to 13 of 13
Thread
  1. Member
    Join Date
    Mar 2011
    Location
    Paris, France
    Search PM
    Hello

    I use the following commands to split an MP4 file:
    Code:
    ffmpeg -ss 00:00:00 -i input.mp4 -t 1:00:00 -c copy input.part1.mp4
    ffmpeg -ss 00:59:50 -i input.mp4 -c copy input.part2.mp4
    Problem is, when viewing the parts in VLC, the second part doesn't seem to start at a keyframe: The picture is crappy, and the viewer has to wait a few seconds until it looks OK; I assume ffmpeg doesn't split at keyframes.

    Is there a way to tell ffmpeg to split on the closest keyframe a few seconds before?

    Thank you.
    Quote Quote  
  2. The current and common problem is ffmpeg doesn't distinguish between non -IDR keyframes. It thinks all "i" frames are keyframes, but only "I" (or IDR) frames are true keyframes. So if you have open GOP's it's not possible to cut with ffmpeg without errors
    Quote Quote  
  3. Member
    Join Date
    Mar 2011
    Location
    Paris, France
    Search PM
    Thanks. What's GOP?
    Quote Quote  
  4. Originally Posted by yetanotherlogin View Post
    Thanks. What's GOP?
    Group of Pictures , used in temporal compression
    https://en.wikipedia.org/wiki/Group_of_pictures
    Quote Quote  
  5. Member
    Join Date
    Mar 2011
    Location
    Paris, France
    Search PM
    Thanks. So ffmpeg isn't the right tool to split MP4 files?

    I like it because it's easy to use since it has a CLI, which is why I use it instead of GUI-based alternatives such as My MP4Box.
    Quote Quote  
  6. If that is the reason, the problem is your original video . You won't get errors from splitting with closed GOPs . ffmpeg will automatically "jump" to the nearest I-frame (or i-frame) it doesn't distinguish between them as mentioned earlier . If GOP's are closed, the all I frames are IDR frames or true keyframes

    Another option is mp4box, but you will have the same problems if you split on non IDR frames
    Quote Quote  
  7. Member
    Join Date
    Mar 2011
    Location
    Paris, France
    Search PM
    I actually use ffmpeg to split 1h+ MP4 files into multiple parts, as downloaded from eg. YouTube.

    I don't know what else to use to have ffmpeg split at GOPs and get clean splits.
    Quote Quote  
  8. If these are from youtube, AFAIK, they use closed GOP settings (at least they used to, unless something has changed recently) - so that shouldn't be the problem

    Then it might be some other ffmpeg bug. Maybe try mp4box instead
    Quote Quote  
  9. Member
    Join Date
    Mar 2011
    Location
    Paris, France
    Search PM
    OK, I'll go back to mp4box instead. Thanks.
    Quote Quote  
  10. Why did you switch to ffmpeg in the first place ? What were you using in mp4box to split ?
    Quote Quote  
  11. Member
    Join Date
    Mar 2011
    Location
    Paris, France
    Search PM
    Because ffmpeg offers more options.
    Quote Quote  
  12. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Near as I remember, it depends on where you place the -ss parameter. I believe before your input seeks to the exact frame and after your input seeks to key frame.

    https://trac.ffmpeg.org/wiki/Seeking
    Quote Quote  
  13. Member
    Join Date
    Mar 2011
    Location
    Paris, France
    Search PM
    Thanks. I'll give it a try.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!