FFmpeg – Split video multiple parts

ffmpegsplitvideo editing

I read the following thread, and the solution works if I want to split a video into pieces every two minutes: Split video file into pieces with ffmpeg

The problem is that I want to split a video into pieces every 15 seconds.

When I use the following command:

for i in {00..49}
 do ffmpeg -i fff.avi -sameq -ss 00:$[ i*2 ]:00 -t 00:00:15 output_$i.avi
done

it will output 15-second video sequences, but not in order. It will skip parts of the video, so I end up with a few 15 second clips, but not all the clips. I want to be able to use ffmpeg to split any video I throw at it into many pieces based on the time I give it.

Best Answer

I found the answer. It turns out I was having problems because I didn't have the proper FFmpeg installed, but a fork of ffmpeg.

This code works for me:

ffmpeg -i fff.avi -acodec copy -f segment -segment_time 10 -vcodec copy -reset_timestamps 1 -map 0 fff%d.avi

fff.avi is the name of the source clip. Change -segment_time 10 to the general duration you want for each segment. If you want each clip to be about 40 seconds, then use -segment_time 40. Use -an after -map 0 if you don't want the resulting clips to have sound.

Related Question