Use the segment muxer. -f segment -segment_time 25 with -c copy writes numbered parts in one pass, each starting on a keyframe. For parts of the exact length, re-encode and force a keyframe at every cut. Every command below ran on the same 2-minute clip, and the results are what came out.
FastStream copy
Instant and lossless. Each part starts on a keyframe, so lengths follow the keyframes.
Five parts of 25, 25, 25, 25 and 20 s, starting on frames 0, 600, 1200, 1800 and 2400. The forced keyframes put a cut exactly every 25 s.
Part lengths
25, 25, 25, 25, 20 s
Run time
9.8 s
Output
34.8 MB
Proof
Where each part starts
The clip has its timecode burned in and a keyframe every 10 seconds. Both commands asked for 25-second parts. Each row is the first frame of one part.
-c copy, -segment_time 25Cuts wait for the next keyframe
0:30, 0:50, 1:20, 1:40The muxer cuts at the first keyframe at or after 0:25, 0:50, 1:15 and 1:40. Two of the four targets fall between keyframes, so those cuts land 5 s late.
Re-encode, -force_key_frames every 25 sA cut every 25 s
0:25, 0:50, 1:15, 1:40Frames 600, 1200, 1800 and 2400, exactly where 25 s parts should start. The last part holds the 20 s that are left.
Returns immediately with a job id. Poll GET /jobs/{id} or register a webhook rather than blocking on the request.
Every variant
Pick the command for your case
Each one ran on the same input. The line under it is what came out. Run times are the best of three runs with FFmpeg 8.0 on one desktop machine, so read them as relative.
The same five parts, plus parts.csv with one row each, like part_001.mp4,30.083333,50.083333. The times sit 0.083 s after the cuts because this clip stores its first frame at 0.083 s.
Three parts of 40 s each. awk divides the duration by 3. The cuts at 0:40 and 1:20 fall on keyframes in this clip. In a file where they do not, each cut moves to the next keyframe.
Three files of 30, 50 and 40 s, one per chapter, with 720, 1200 and 960 frames: all 2880, none twice. ffprobe lists the chapter ends and paste joins them with commas. tr strips the Windows line endings.
186 ms run6.3 MB120.02 s long
Gotchas
Where it goes wrong
Why are my parts not the length I asked for?
With -c copy, a part can only start on a keyframe. The segment muxer cuts at the first keyframe at or after each multiple of -segment_time. This clip has a keyframe every 10 s, so -segment_time 25 cut at 0:30, 0:50, 1:20 and 1:40, and the parts ran 30, 20, 30, 20 and 20 s.
List the keyframes to see where a copy cut can land:
0, 10, 20 and every 10 s up to 110. A -segment_time that is a multiple of 10 gives equal parts here. For any other length, re-encode with -force_key_frames.
Why does each part not start at 0?
Without -reset_timestamps 1, each part keeps the timestamps it had in the source, so the second part of a split starts where it sat in the original.
part_001.mp4 starts at 30.014 s and part_004.mp4 at 100.008 s. With -reset_timestamps 1, parts 1 to 4 start at 0.000 s.
Can FFmpeg split a video by file size?
Not in one command. The segment muxer cuts by time only. -fs stops writing at a size, so it gives you the first part and nothing after it:
ffmpeg-iin.mp4-ccopy-fs10Mpart.mp4
One file of 10,266,317 bytes holding the first 58.1 s. -fs 10M means 10,000,000 bytes, and the file came out 266 KB over.
Equal times do not give equal sizes on a stream copy either. Three 40 s parts of this clip came out at 6.2, 13.4 and 10.3 MB, because busy scenes take more bits. Cap the bit rate while you re-encode and the sizes even out:
Three 40 s parts of 7.1, 7.7 and 7.6 MB. 1,500 kbps of video plus 128 kbps of audio is 8.1 MB per 40 s, so every part stayed under that.
Segment muxer, or one -ss and -to command per part?
The segment muxer. It reads the file once and puts every frame in exactly one part. A loop of -ss and -to with -c copy is the top Stack Overflow answer for splitting by chapter, and on this clip the parts overlapped: