Skip to content

(FFmpeg) How to Splice a Video into Segments?

Splicing a video (or dividing a video into multiple segments) is a common way to break large files into smaller parts. This is commonly found in streaming but can also be used to break up a video into smaller clips. 

Here is a basic example where the input is a 20 second clip with the desired result of multiple 5 second segments:

  $ ffmpeg -i input.mp4 -c copy -f segment -segment_time 00:00:05 -reset_timestamps 1 output_%02d.mp4   

Naturally, it is expected that each clip is 5 seconds long. Unfortunately, -segment_time is not always accurate and takes the time value as a recommendation.

The FFmpeg documentation states using -force_key_frames is one way to force each cut length but by frames not duration.

segment_time
	Indicates the segment duration to time (default value 2)

-reset_timestamps
	Indicates requiring each segment to begin with a near-zero timestamp which is useful for when each segment must have playback (optional)

Challenge: How would you do this with an audio file instead?