How to Split a Video into Fixed-Length Parts with FFmpeg
With -f segment, FFmpeg can split a video into files of a fixed length, such as every 10 seconds or every 10 minutes, in a single command. This is useful for cutting a long recording into manageable pieces, or for uploading to a service that limits clip length.
However, when I split without re-encoding, the individual lengths were not uniform. Splitting a 65-second video every 10 seconds in my test environment produced files of 16.7, 8.3, 8.3, 8.3, 16.7, and 6.7 seconds. The cuts can only happen at keyframe positions. Re-encoding with a keyframe every 10 seconds and adding -segment_time_delta produced files of exactly 10 seconds, except for the last one.
The test environment was a 4-core virtual machine running Ubuntu 24.04.5 with FFmpeg 6.1.1 (Ubuntu package 6.1.1-3ubuntu5). The source was a 65-second MP4 (H.264 at 1280×720 30fps, AAC) generated from FFmpeg's test video and audio, with the elapsed time drawn in the top-left corner. I checked playback of the split files in Chromium 157.0.8103.78, driven by Playwright 1.63.0, using the video element. I did not test splitting into formats other than MP4, videos with a variable frame rate (such as phone recordings), or codecs other than H.264.
Command to split every 10 seconds
The following command splits the video every 10 seconds without re-encoding. Create the output folder (copy here) beforehand.
mkdir copy
ffmpeg -i src.mp4 -c copy -f segment -segment_time 10 -reset_timestamps 1 copy/part_%03d.mp4
The options mean the following. The explanations are based on the segment section of the official FFmpeg documentation and the description of the main ffmpeg options.
| Option | Meaning |
|---|---|
-c copy |
Copy the video and audio without re-encoding |
-f segment |
Write the output as multiple files |
-segment_time 10 |
Target length of each file, in seconds. The default is 2 |
-reset_timestamps 1 |
Restart the timestamps of each split file from around 0 seconds (explained in a later section) |
part_%03d.mp4 |
Output file name. %03d is replaced with a number starting at 000 |
When I ran this in the test environment, it created six files in 0.17 seconds. The table below shows the length of each file, checked with ffprobe (size is in bytes).
copy/part_000.mp4 start_time=0.045000|duration=16.687683|size=6720371
copy/part_001.mp4 start_time=0.000000|duration=8.333333|size=3360322
copy/part_002.mp4 start_time=0.000000|duration=8.333333|size=3376375
copy/part_003.mp4 start_time=0.000000|duration=8.333333|size=3369962
copy/part_004.mp4 start_time=0.000000|duration=16.666667|size=6714520
copy/part_005.mp4 start_time=0.000000|duration=6.667000|size=2703951
The files are not 10 seconds each. The video frames in the six files add up to 1950, which matches the original video (65 seconds × 30 fps).
Lengths don't match because cuts can only happen at keyframes
I used ffprobe to find the times of the keyframes (frames that can be decoded on their own) in the original video.
ffprobe -v error -select_streams v -skip_frame nokey -show_entries frame=pts_time -of csv=p=0 src.mp4
0.000000,
8.333333
16.666667
25.000000
33.333333
41.666667
50.000000
58.333333
In this video, keyframes occur only every 8.33 seconds (every 250 frames). The official documentation says that each split file starts with a keyframe, and that if there is no keyframe at the split time, the split happens at the first keyframe after it. -c copy does not re-encode, so the keyframe positions stay as they are.
Split times are counted from the start of the video, not from the end of the previous file: 10 seconds, 20 seconds, 30 seconds, and so on. I confirmed this in the libavformat/segment.c source code in FFmpeg 6.1.1. So the first split happened at the first keyframe after 10 seconds, which is 16.67 seconds. The next split happened at 25 seconds, the first keyframe after 20 seconds.
However, there is a keyframe at exactly 50 seconds, and the split did not happen there. It continued to 58.33 seconds. The next section explains why and how to fix it.
Split at exactly 10-second intervals
To split at exactly 10-second intervals, re-encode the video and insert a keyframe every 10 seconds. You specify the keyframe positions with -force_key_frames. I adapted the "every 5 seconds" example from the -force_key_frames description in the ffmpeg documentation to every 10 seconds.
mkdir enc_delta2
ffmpeg -i src.mp4 -c:v libx264 -force_key_frames "expr:gte(t,n_forced*10)" -c:a aac -b:a 128k \
-f segment -segment_time 10 -segment_time_delta 0.0167 -reset_timestamps 1 enc_delta2/part_%03d.mp4
All files except the last one were exactly 10 seconds and 300 frames.
part_000.mp4 start_time=0.045000|duration=10.021016|size=3842338|frames=300|first_packet_flags=K__
part_001.mp4 start_time=0.000000|duration=10.000000|size=3877513|frames=300|first_packet_flags=K__
part_002.mp4 start_time=0.000000|duration=10.000000|size=3854468|frames=300|first_packet_flags=K__
part_003.mp4 start_time=0.000000|duration=10.000000|size=3865627|frames=300|first_packet_flags=K__
part_004.mp4 start_time=0.000000|duration=10.000000|size=3825434|frames=300|first_packet_flags=K__
part_005.mp4 start_time=0.000000|duration=10.000000|size=3844466|frames=300|first_packet_flags=K__
part_006.mp4 start_time=0.000000|duration=5.002000|size=1922040|frames=150|first_packet_flags=K__
frames is the number of video frames. K in first_packet_flags means the first frame of the file is a keyframe.
Without -segment_time_delta, the inserted keyframes did not cause a split
The -segment_time_delta 0.0167 option was essential. When I re-encoded with the same command but without this option, the first file had 550 frames (18.33 seconds; ffprobe reported a duration of 18.35 seconds), and the rest drifted off the 10-second marks.
part_000.mp4 start_time=0.045000|duration=18.354349|size=7045216|frames=550|first_packet_flags=K__
part_001.mp4 start_time=0.000000|duration=10.000000|size=3883548|frames=300|first_packet_flags=K__
(略)
part_005.mp4 start_time=0.000000|duration=6.669000|size=2581704|frames=200|first_packet_flags=K__
I re-encoded with the same settings and wrote the result as a single MP4 to check its keyframes. There were keyframes at 10, 20, 30 seconds, and so on, as specified by -force_key_frames. There were also keyframes at 8.33 and 18.33 seconds, which I had not specified. The first split did not happen at the keyframe at exactly 10 seconds. It happened at the keyframe at 18.33 seconds.
0.000000,K__
8.333333,K__
10.000000,K__
18.333333,K__
20.000000,K__
(略)
60.000000,K__
The cause was rounding in how segment decides split times. What makes this confusing is that the times segment uses are offset by 0.0667 seconds (2 frames) from the times ffprobe reports. When I ran with -v verbose, segment showed that the first file started at the packet with time 0.0667 seconds (pts_time:0.0666667). ffprobe reports this frame as 0 seconds.
Reading segment.c, the time of this first frame, rounded to microseconds, is added to each split time (10 seconds, 20 seconds, and so on). Since 0.0666… seconds rounds to 0.066667 seconds, the split reference for the 10-second mark becomes 10.066667 seconds. The keyframe at exactly 10 seconds is 10.0666… seconds in segment's time, which is just short of that reference, so it was not used as a split point. The skipped split at 50 seconds has the same cause.
segment_time_delta tells segment to start a new file at a keyframe whose time is at least the split time minus this value. The official documentation describes it for cases where keyframes inserted with -force_key_frames come slightly before the requested time because of rounding. The cause in this case is different, but following the documentation's guidance, I set it to half a frame at 30fps (1/60, about 0.0167 seconds). With that, the split happened at the keyframe at exactly 10 seconds. Adding -segment_time_delta 0.0167 when splitting with -c copy also made the split happen at the 50-second keyframe.
I also tried splitting a video that already had the keyframes inserted, using -c copy and -segment_time_delta 0.0167. This gave seven files: six of 10 seconds and a final 5-second file.
The following figure compares the split results for the three cases.

To split into exactly equal lengths, insert keyframes at the split positions with -force_key_frames, and set -segment_time_delta to 1/(2×frame rate).
Re-encoding takes more time. In the test environment, splitting with -c copy took 0.17 seconds, while re-encoding took 18.7 seconds. If exact lengths don't matter, use -c copy. Re-encode only when you need the lengths to match.
Why -reset_timestamps 1
Without -reset_timestamps 1, each split file kept its original timestamps from the source video. In ffprobe, the second file (part_001.mp4) starts at 16.685 seconds.
part_000.mp4 start_time=0.045000|duration=16.687683|size=6720371|frames=500|first_packet_flags=K__
part_001.mp4 start_time=16.685000|duration=8.381341|size=3360346|frames=250|first_packet_flags=K__
part_002.mp4 start_time=25.005000|duration=8.394349|size=3376399|frames=250|first_packet_flags=K__
(略)
I loaded this second file in the video element in Chromium, started playback with play(), and compared the values after 2 seconds.
| Value | Without -reset_timestamps 1 | With -reset_timestamps 1 |
|---|---|---|
duration |
21.03 seconds | 8.33 seconds |
currentTime right after loading |
8.38 seconds | 0 seconds |
currentTime after 2 seconds of playback |
18.60 seconds | 1.94 seconds |
Without the option, the file has 250 frames (8.33 seconds) but a duration of 21.03 seconds. Playback also started at 8.38 seconds and jumped to 18.60 seconds. Frames were drawn in both cases (61 and 63 frames in 2 seconds), but the time and duration values did not match the content. The official documentation also describes reset_timestamps as making split files easier to play. If you use each file as an independent video, add this option.
Write the split times to a list
With -segment_list, you can create a list of the split file names and the start and end time of each in the original video. Use -segment_list_type csv to write the list as CSV.
mkdir list
ffmpeg -i src.mp4 -c copy -f segment -segment_time 10 -reset_timestamps 1 \
-segment_list list/parts.csv -segment_list_type csv list/part_%03d.mp4
part_000.mp4,0.000000,16.733333
part_001.mp4,16.733333,25.066667
part_002.mp4,25.066667,33.400000
part_003.mp4,33.400000,41.733333
part_004.mp4,41.733333,58.400000
part_005.mp4,58.400000,65.066667
The first column is the file name, the second is the start time, and the third is the end time, all in seconds. Except for the first value of 0.000000, each boundary is 0.0667 seconds later than the keyframe time shown by ffprobe. The final value of 65.066667 is 0.0667 seconds later than the video's length of 65 seconds. This is the same offset in segment's times described in the previous section. To find the position in the original video, subtract this difference.
The official documentation also lists ffconcat (a format that FFmpeg's concat demuxer can read) and m3u8 as other values for -segment_list_type.
Join the split files with concat
I joined the split files in order using concat (-f concat). Whether the files were split with -c copy or re-encoded, the result was a single file of about 65.02 seconds and 1950 frames.
ffmpeg -f concat -safe 0 -i concat.txt -c copy joined.mp4
concat.txt lists the split files in order, one per line, using full paths such as file '/path/to/copy/part_000.mp4' (/path/to is a placeholder). According to the concat documentation, the default -safe setting accepts only file names made of a limited set of characters and relative paths. Because I used full paths, I added -safe 0.




