How to Split a Video into Short Clips with FFmpeg

How to Split a Video into Short Clips with FFmpeg

josen
josen
8 min read

How to Split a Video into Short Clips with FFmpeg

You’ve finished a long screen recording, and now you need separate files for the useful parts. A timer can divide it into manageable chunks, but it doesn’t know where an explanation ends or a new demonstration begins.

I’d choose the split points before choosing the command. For review copies or batch processing, regular intervals are convenient. For clips people will watch separately, mark the topic changes and use those timestamps. FFmpeg supports both approaches; the complication is that fast stream copying won’t necessarily cut at the exact moments you request.

Splitting also differs from extracting a single passage. Here, the aim is to produce a sequence of files from the recording, including the remaining footage after the last cut.

Choose regular intervals or editorial cut points

An interval-based split is useful when you’re sending a recording for review or preparing smaller files for another tool. You might request a new file every minute and accept small differences in the actual boundaries.

For a tutorial, those same boundaries can land halfway through a sentence. I’d watch the recording and note where each topic starts instead. In the example below, the chosen cuts are at 1:30, 3:30 and 6:00; use your own timestamps for the actual recording.

A requested interval is not a guaranteed maximum clip length. If a delivery limit is strict, you’ll need to inspect the outputs rather than assume that setting the interval to that limit is sufficient.

For variations on either plan, the FFmpeg splitting examples include regular segments and selected time ranges. The commands below keep the focus on producing multiple clips, with the keyframe trade-off made explicit.

Before running them, make sure ffmpeg and ffprobe are available in your terminal. Replace recording.mp4 with your file, and create the empty output folder named in each example. Use a fresh folder for each run so earlier clips don’t get mixed with new results.

How to Split a Video into Short Clips with FFmpeg

 

Make roughly one-minute clips without re-encoding

Start with stream copying when nearby cut points are acceptable. For this MP4 example, the selected source streams must be compatible with MP4, such as H.264 video and AAC audio.

Create an empty folder named copy_clips, then run:

ffmpeg -hide_banner -i "recording.mp4" -map 0:v:0 -map "0:a:0?" -c copy -f segment -segment_time 60 -reset_timestamps 1 “copy_clips/clip_%03d.mp4”

The files use names such as clip_000.mp4 and clip_001.mp4. The maps select the first video stream and, if present, the first audio stream. Other audio tracks and subtitles aren’t included by these examples.

-c copy copies the selected encoded streams without re-encoding them. -segment_time 60 requests regular split times; -reset_timestamps 1 requests near-zero starting timestamps for each output.

The boundary still depends on the source. The segment muxer starts a new file at an eligible keyframe; when the requested point doesn’t align, the next suitable keyframe can move the cut later. The remainder at the end can also be shorter. Don’t describe these files as exactly one minute each.

 

Split at your chosen timestamps

Use a timestamp list when the recording’s structure should decide the clips. Create an empty folder named chapter_clips and run:

ffmpeg -hide_banner -i "recording.mp4" -map 0:v:0 -map "0:a:0?" -c copy -f segment -segment_times 90,210,360 -reset_timestamps 1 “chapter_clips/chapter_%03d.mp4”

For a recording longer than six minutes, this requests cuts at 1:30, 3:30 and 6:00, followed by a final clip containing the remainder. The values are positions measured from the start, not the lengths of the individual clips.

But the timestamp list doesn’t remove the stream-copy limitation. A cut intended to start with the next explanation may arrive late, leaving its opening words in the preceding file. Check each transition before treating the files as finished chapters.

If the chosen moments are essential to the edit, I’d move to re-encoding rather than keep adjusting timestamps around the source’s existing keyframes.

Re-encode when the boundaries need more control

Re-encoding lets you request new keyframes at the intended boundaries. This example requires the libx264 video encoder and AAC audio encoding. Create an empty folder named encoded_clips:

ffmpeg -hide_banner -i "recording.mp4" -map 0:v:0 -map "0:a:0?" -c:v libx264 -crf 20 -preset medium -flags +cgop -force_key_frames "expr:gte(t,n_forced*60)" -c:a aac -b:a 128k -f segment -segment_time 60 -reset_timestamps 1 “encoded_clips/clip_%03d.mp4”

Here, the forced-keyframe expression requests a keyframe at each interval on the output timeline. Encoding takes additional work and changes the encoded media, so I’d reserve it for cases where the copied boundaries aren’t suitable.

For custom cut points, replace the expression with -force_key_frames "90,210,360" and replace -segment_time 60 with -segment_times 90,210,360. Both lists must describe the same intended boundaries.

How to Split a Video into Short Clips with FFmpeg

That still isn’t a promise of mathematically identical durations. Frames occupy discrete timestamps, forcing can involve rounding, and the final clip contains whatever remains. Variable-frame-rate recordings and unusual timestamps deserve particular care. Verify the generated files against the actual delivery requirement.

Check a boundary before processing the whole recording

A successful command doesn’t establish that the clips are ready to use. Inspect a representative output’s reported duration with ffprobe’s duration query:

ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 “encoded_clips/clip_000.mp4”

Repeat for other files as needed, especially the last one. Duration alone won’t tell you whether a sentence was divided awkwardly or a clip begins with a poor viewing point, so playback is part of the check.

How to Split a Video into Short Clips with FFmpeg

Before committing to a long recording:

  1. Try the chosen approach on a short representative excerpt that includes a planned boundary. Open both neighboring clips and listen across the transition, checking the first visible frame and whether the intended audio is present.
  2. If that boundary suits the job, apply the same approach to the full source and review the resulting transitions and final remainder. If it doesn’t, change the cut plan or encoding approach before creating a larger batch.

Discussion (0 comments)

0 comments

No comments yet. Be the first!