Mute part of a video with FFmpeg

Set volume=0 with an enable range in seconds, between(t,17,19.5), and copy the video with -c:v copy. Only the audio is re-encoded. On the test clip the silence ran from 17.019 to 19.520 s and the picture stayed byte-identical.

Mute Re-encode

Silences one range and leaves the rest of the sound and all of the picture as they were.

ffmpeg -i in.mp4 -af "volume=enable='between(t,17,19.5)':volume=0" -c:v copy out.mp4

Silent from 17.019 to 19.520 s, untouched everywhere else. The video stream is identical to the input's.

Silent
17.019 to 19.520 s
Video
Copied, same md5
Run time
752 ms
Output
4.5 MB

Proof

The gap in the waveform

Waveforms of the 40 s clip, drawn from each output on the same scale. Each pixel column is about 42 ms.
in.mp4
Waveform of the 40-second dialogue scene before muting
0 gaps The scene as released. The line at 17 to 19.5 s is the burst a little left of the middle.
between(t,17,19.5) Line removed, the rest untouched
The same waveform with a flat gap where the line at 17 seconds was
2.5 s A flat gap from 17.019 to 19.520 s. Everything around it matches the input.
between(t,17,19.5)+between(t,25.4,27) Two ranges, one filter
The waveform with two flat gaps, at 17 and at 25.4 seconds
2 gaps The second gap runs from 25.409 to 27.007 s, over "A dragon."
sine=f=1000, amix Bleeped instead of silent
The waveform with a solid block of tone where the line at 17 seconds was
1 kHz The line replaced by a 1,000 Hz tone. Outside the range the level matches the input within 0.1 dB.

Footage: Sintel, © Blender Foundation, CC BY 3.0.

Run it

Run it on Rendobar

Send the same command from your code. The job fetches each input from its URL and returns the output file's URL when it finishes.

job.ts
import { createClient } from "@rendobar/sdk";
const rb = createClient({ apiKey: process.env.RENDOBAR_API_KEY });
const job = await rb.jobs.run({
type: "ffmpeg",
inputs: {
"in.mp4": "https://cdn.rendobar.com/examples/mute-audio-section/in.mp4",
},
params: {
command: "ffmpeg -i in.mp4 -af \"volume=enable='between(t,17,19.5)':volume=0\" -c:v copy out.mp4",
},
});
console.log(job.output.file.url);

Install with npm i @rendobar/sdk. jobs.run() submits and waits, so it returns the finished job in one call.

terminal
curl https://api.rendobar.com/jobs \
-H "Authorization: Bearer $RENDOBAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "ffmpeg",
"inputs": {
"in.mp4": "https://cdn.rendobar.com/examples/mute-audio-section/in.mp4"
},
"params": {
"command": "ffmpeg -i in.mp4 -af \"volume=enable='\''between(t,17,19.5)'\'':volume=0\" -c:v copy out.mp4"
}
}'

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.

  1. Mute several sections

    Re-encode
    ffmpeg -i in.mp4 -af "volume=enable='between(t,17,19.5)+between(t,25.4,27)':volume=0" -c:v copy out.mp4

    Silent from 17.019 to 19.520 and from 25.409 to 27.007 s. + means or. Add as many ranges as you need.

    721 ms run 4.4 MB 40.00 s long

  2. Lower the volume of a section instead of muting it

    Re-encode
    ffmpeg -i in.mp4 -af "volume=enable='between(t,17,19.5)':volume=0.2" -c:v copy out.mp4

    The range plays at a fifth of its level: -47.2 dB RMS against -33.1 dB in the input.

    782 ms run 4.5 MB 40.00 s long

  3. Mute from a time to the end

    Re-encode
    ffmpeg -i in.mp4 -af "volume=enable='gte(t,30)':volume=0" -c:v copy out.mp4

    Silent from 30.018 s to the end. gte means greater than or equal, so you never need the duration.

    638 ms run 4.3 MB 40.00 s long

  4. Mute the first 5 seconds

    Re-encode
    ffmpeg -i in.mp4 -af "volume=enable='lt(t,5)':volume=0" -c:v copy out.mp4

    Silent from 0 to 5.013 s, sound from there on.

    687 ms run 4.4 MB 40.00 s long

  5. Mute a section and keep the audio quality

    Re-encode
    ffmpeg -i in.mp4 -af "volume=enable='between(t,17,19.5)':volume=0" -c:v copy -c:a aac -b:a 192k out.mp4

    AAC at 185.6 kb/s, above the 165 kb/s source. Without -b:a the re-encode came out at 124.7 kb/s.

    844 ms run 4.8 MB 40.00 s long

  6. Bleep a section instead of muting it

    Re-encode
    ffmpeg -i in.mp4 -f lavfi -i sine=f=1000:r=48000 -filter_complex "[0:a]volume=enable='between(t,17,19.5)':volume=0[a];[1:a]volume=enable='not(between(t,17,19.5))':volume=0[b];[a][b]amix=inputs=2:duration=first:normalize=0[out]" -map 0:v -map "[out]" -c:v copy out.mp4

    A 1 kHz tone over 17 to 19.5 s, peak -21.1 dB. The tone is muted everywhere else, and normalize=0 keeps the dialogue at its level. Without it, amix lowered everything by 6 dB.

    767 ms run 4.5 MB 40.00 s long

Gotchas

Where it goes wrong

Can I mute a section without re-encoding?

The video, yes. The audio, no. A filter has to decode the sound to change it, so the audio is always re-encoded, and -c:v copy keeps the picture out of it.

On the test clip the video stream came out with the same md5 as the input. The audio dropped from 165 kb/s to 124.7 kb/s, what the AAC encoder gives when no bitrate is set. Add -c:a aac -b:a 192k to stay above the source.

Why do I get "Error parsing filterchain"?

Two usual causes. The first is a comma inside between() with no single quotes around it. FFmpeg reads that comma as the end of the filter:

ffmpeg -i in.mp4 -af "volume=enable=between(t,17,19.5):volume=0" -c:v copy out.mp4

No option name near '0', then Error parsing filterchain. No file written.

The second is a time written as minutes and seconds. The expression only knows numbers:

ffmpeg -i in.mp4 -af "volume=enable='between(t,0:17,0:19.5)':volume=0" -c:v copy out.mp4

Error parsing filterchain. Write 17, or 1*60+17 for 1:17.

Keep double quotes around the whole filter and single quotes around the expression, as in every command on this page.

How exact is the muted range?

To the audio frame. The filter checks t once per frame, at the frame's start, and the frames in this file are 1,024 samples, 21.3 ms at 48 kHz. A frame that starts inside the range is muted whole.

ffmpeg -i in.mp4 -vn -af "volume=enable='between(t,17,19.5)':volume=0" out.wav

Silent from 17.003 to 19.520 s, two frame edges. In the AAC version the silence starts at 17.019 s, because the encoder blends across the edge.

To check your own output, list its silences:

ffmpeg -i out.mp4 -vn -af silencedetect=n=-80dB:d=0.3 -f null -

On the muted MP4: silence_start: 17.018687, silence_end: 19.519938.

Related: Remove audio, Normalize audio, Mix audio tracks, Trim a video, Remove silence.

Your command. Our infrastructure.

Bring your own commands. Run them on scalable CPU and GPU infrastructure, and pay only for compute time.