How to Split Video by Silence with FFmpeg
This guide explains how to automatically split a video into smaller segments based on silent intervals using FFmpeg. By detecting the silent parts in your video’s audio track, you can generate precise timestamps and use them to cut your video into individual, high-quality clips without re-encoding.
Step 1: Detect Silence Timestamps
First, you need to analyze the video’s audio track to find where the
silent parts occur. FFmpeg has a built-in filter called
silencedetect for this purpose.
Run the following command in your terminal:
ffmpeg -i input.mp4 -af silencedetect=noise=-30dB:d=0.5 -f null -Parameter Breakdown:
noise=-30dB: The noise threshold. Anything quieter than -30 decibels is considered silence. You can adjust this (e.g.,-50dBfor quieter environments).d=0.5: The minimum duration of silence in seconds. In this case, any silence lasting 0.5 seconds or longer will be detected.-f null -: Instructs FFmpeg to process the file without writing an output video, which makes the detection process extremely fast.
After running this command, look at the terminal output. You will see lines containing the silence timestamps:
[silencedetect @ 0x...] silence_start: 12.504
[silencedetect @ 0x...] silence_end: 13.211 | silence_duration: 0.707
[silencedetect @ 0x...] silence_start: 45.120
[silencedetect @ 0x...] silence_end: 46.010 | silence_duration: 0.890
Note down the silence_start (or the midpoint of the
silence) timestamps.
Step 2: Split the Video Using Timestamps
Once you have the timestamps where the silence occurs, you can use
FFmpeg’s segment muxer to split the video.
Using the example timestamps from the step above (silences starting around 12.5 and 45.1 seconds), run the following command:
ffmpeg -i input.mp4 -f segment -segment_times 12.5,45.1 -c copy output_%03d.mp4Parameter Breakdown:
-f segment: Specifies the segment muxer.-segment_times 12.5,45.1: A comma-separated list of timestamps where the video should be split.-c copy: Copies the video and audio streams without re-encoding, preserving the original quality and completing the process instantly.output_%03d.mp4: The output naming pattern. This will generate files namedoutput_000.mp4,output_001.mp4,output_002.mp4, and so on.
Note: Because -c copy splits the video at the
nearest keyframe (I-frame), the split might not be 100% frame-accurate.
If you require exact frame-accurate cuts, omit -c copy to
re-encode the video during the split.