1

How do I split a large mp4 file using ffmpeg, into smaller clips, which are 15 seconds each?

1
  • what video player are you using to play the files? – mchid Jul 13 '15 at 20:25
5

Use the segment muxer:

ffmpeg -i ~/Desktop/in.mp4 -c copy -map 0 -f segment -segment_time 15 -reset_timestamps 1 -segment_format_options movflags=+faststart out%03d.mp4
  • This example will use stream copy mode, so re-encoding will be avoided. However, it has to cut on the nearest keyframes so accuracy is not guaranteed. Remove -c copy if you need more accuracy, but note that re-encoding will occur.

  • Output files in this example will be named out001.mp4, out002.mp4, etc.

5
  • Thanks, and if the video file is located in the Ubuntu desktop, how do I include the path in the command? )Let's assume the output files are created in the desktop). Kindly let me know – Dominic Isaiah Jun 24 '15 at 8:51
  • @DominicIsaiah I updated the example to include the Desktop in the path to the input. See Ubuntu Wiki: Using the Terminal - File & Directory Commands for more info. – llogan Jun 24 '15 at 16:46
  • Some of the clips would play, but others would show error messages or would not play at all. I feel some of the clips got corrupted. Is there a way to fix this? – Dominic Isaiah Jun 26 '15 at 17:43
  • 1
    @DominicIsaiah Please provide a pastebin link showing your command and the complete console output. What player did you use? Can you provide the input file? – llogan Jun 26 '15 at 18:14
  • I used the same command which you mentioned "ffmpeg -i ~/Desktop/in.mp4 -codec copy -map 0 -f segment -segment_time 15 \ -segment_format_options movflags=+faststart out%03d.mp4" – Dominic Isaiah Jul 3 '15 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.