FFmpeg splitting large files

前端 未结 1 432
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 09:50

I need to split a large video file into multiple pieces quickly and without files with errors. The basic idea is, I have a 2GB video file which I want to change to multiple

相关标签:
1条回答
  • 2020-11-29 10:15

    Use the segment muxer to break the input into segments:

    ffmpeg -i testfile.mp4 -c copy -f segment -segment_time 1200 testfile_piece_%02d.mp4
    

    This will split the source at keyframes, so segments may not be exactly 1200 seconds long. And the timestamps aren't reset, so some players will fail to play the 2nd and latter segments. If playability is needed, insert -reset_timestamps 1.

    After the parallel encoding, you can stitch the generated segments by first creating a text file seg.txt like this

    file 'encoded_testfile_piece_00.mp4'
    file 'encoded_testfile_piece_01.mp4'
    file 'encoded_testfile_piece_02.mp4'
    file 'encoded_testfile_piece_03.mp4'
    

    And then running

    ffmpeg -f concat -i seg.txt -c copy -fflags +genpts encoded_full.mp4
    
    0 讨论(0)
提交回复
热议问题