VideoHelp Forum




+ Reply to Thread
Results 1 to 17 of 17
  1. 1. When I split videos by file size, I only got one file.

    2. When I split videos by keyframes, the videos are longer than they're supposed to be.

    How do I fix these problems?

    Code:
    ffmpeg -i input.mp4 -fs 200M -c copy output_segment_%03d.mp4
    Code:
    ffmpeg -i input.mp4 -f segment -segment_time 0 -c copy output%03d.mp4
    Last edited by TitleScreenOP; 11th May 2024 at 22:23.
    Quote Quote  
  2. When I split videos by file size, I only got one file.
    Code:
    -fs 200M
    -fs limit_size (output)

    Set the file size limit, expressed in bytes. No further chunk of bytes is written after the limit is exceeded. The size of the output file is slightly more than the requested file size.
    => that is not a split option, but an option that limits the output size.

    Code:
     -segment_time 0
    segment_time time

    Set segment duration to time, the value must be a duration specification. Default value is "2". See also the segment_times option.

    Note that splitting may not be accurate, unless you force the reference stream key-frames at the given time. See the introductory notice and the examples below.
    => 0 seems like an odd choice


    Did you read https://ffmpeg.org/ffmpeg-formats.html#segment_002c-stream_005fsegment_002c-ssegment ?

    Also notice that splitting will only occur on key/idr frames (if no reencoding is done), thus independent of how you split, it's likely to be inaccurate.
    Additionally, if your content uses open-gop, you might not be able to split it at all.

    If you want to split an mp4 into 200MB chunks, using MP4Box might be better suited:
    Code:
    mp4box -split-size 200000 input.mp4
    see: https://wiki.gpac.io/MP4Box/mp4box-dump-opts/#file-dumping

    Cu Selur
    Last edited by Selur; 12th May 2024 at 05:26.
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  3. Will splitting videos by using MP4Box be lossless? As well as remuxing mkv files to mp4? What if I used -crf 0 for splitting H.265 videos to H.264? How do I make it not cut at keyframes?
    Quote Quote  
  4. Will splitting videos by using MP4Box be lossless?
    Yes, but it will also only cut on I/IDR-frames.
    As well as remuxing mkv files to mp4?
    That totally depends on what your content is. mvk supports way more formats (video/audio/subtitle) than mp4.
    If you want to cut mkv files you could use mkvtoolnix gui. (cut will be lossless and only on key frames)
    What if I used -crf 0 for splitting H.265 videos to H.264?
    Assuming your input isn't raw video, you will get way !huge!r files.
    How do I make it not cut at keyframes?
    You use a tool what either completely reencodes or supports smart reencoding (only encodes at the start/end) of the cuts.

    Cu Selur
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  5. You use a tool what either completely reencodes or supports smart reencoding (only encodes at the start/end) of the cuts.
    I mean when splitting videos using ffmpeg?
    Quote Quote  
  6. I mean when splitting videos using ffmpeg?
    ffmpeg has no option for 'smart encoding', thus without re-encoding it can only cut on key-frames.
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  7. Wait, I got something. When I split videos by keyframe, PotPlayer plays them incorrectly, but MPC-HC does. How do I fix the problem on PotPlayer?
    Quote Quote  
  8. No clue about PotPlayer,...
    How did you split them? (hopefully not using '-f segment' since that is not really meant for all containers,....
    stream_segment is a variant of the muxer used to write to streaming output formats, i.e. which do not require global headers, and is recommended for outputting e.g. to MPEG transport stream segments. ssegment is a shorter alias for stream_segment.
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  9. Originally Posted by Selur View Post
    No clue about PotPlayer,...
    How did you split them? (hopefully not using '-f segment' since that is not really meant for all containers,....
    stream_segment is a variant of the muxer used to write to streaming output formats, i.e. which do not require global headers, and is recommended for outputting e.g. to MPEG transport stream segments. ssegment is a shorter alias for stream_segment.
    So how was I supposed to split H.264/H.265 videos in mp4/mkv/mov files, then?
    Quote Quote  
  10. mp4/mov -> mp4box
    mkv -> mkvtoolnix (mkvmerge if you use the command line)

    Cu Selur

    Ps.: with some scripting setting start&end points it might also be possible using ffmpeg (there might be a script for it somewhere in the forum)
    Last edited by Selur; 12th May 2024 at 08:51.
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  11. Originally Posted by Selur View Post
    mp4/mov -> mp4box
    mkv -> mkvtoolnix (mkvmerge if you use the command line)

    Cu Selur

    Ps.: with some scripting setting start&end points it might also be possible using ffmpeg (there might be a script for it somewhere in the forum)
    Anything else? How do I make it so that the limit is strictly the file size I want?
    Quote Quote  
  12. That is not possible, since:
    a. you can only cut on key frames
    b. gops will have different sizes
    So, strictly splitting into xy MB chunks while being able to still play the files is not possible.
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  13. Originally Posted by Selur View Post
    I mean when splitting videos using ffmpeg?
    ffmpeg has no option for 'smart encoding', thus without re-encoding it can only cut on key-frames.
    I'm fine with re-encoding. How do I cut at regular frames using ffmpeg?
    Quote Quote  
  14. You seek to the position you want to start and then set the number of frames (or length of the clip) you want to output. (read the Seeking page,...)
    (Probably easier to use Avidemux or similar,...)

    Cu Selur
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  15. Originally Posted by Selur View Post
    You seek to the position you want to start and then set the number of frames (or length of the clip) you want to output. (read the Seeking page,...)
    (Probably easier to use Avidemux or similar,...)

    Cu Selur
    And splitting them with re-encoding using ffmpeg?
    Last edited by TitleScreenOP; 12th May 2024 at 09:55.
    Quote Quote  
  16. And splitting them with re-encoding using ffmpeg?
    1.
    ffmpeg has no option for 'smart encoding', thus without re-encoding it can only cut on key-frames.
    2.
    You seek to the position you want to start and then set the number of frames (or length of the clip) you want to output. (read the Seeking page,...)
    answered that.
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  17. Member The_Doman's Avatar
    Join Date
    Feb 2004
    Location
    Netherlands
    Search PM
    Originally Posted by Selur View Post
    (Probably easier to use Avidemux or similar,...)
    I would also give it a try with Avidemux.
    It seems to make correctly playable cuts and lets you navigate easily from keyframe to keyframe.
    Quote Quote  



Similar Threads

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