Ubuntu – How to automatically segment video using ffmpeg without re-encoding

convertffmpegvideo

I have a 2 hour video. I want to make 30 minute sections but avoid re-encoding. So 2 hours of video into four 30 minute videos. How can I do this using a single ffmpeg command?

I am using Ubuntu 16.04 64-bit.

Best Answer

  • You can use the segment muxer:

    ffmpeg -i input.mp4 -map 0 -c copy -f segment -segment_time 1800 -reset_timestamps 1 output_%03d.mp4
    
    • In this example output files will be named output_000.mp4, output_001.mp4, etc.

    • Segments may not be exactly 30 minutes long because it must cut on keyframes only.