Insert Blank Audio into Video with FFmpeg

This article provides a quick, practical guide on how to add a silent or blank audio track to an existing video file using FFmpeg on Linux. Whether your original video has no audio stream at all, or you need to replace a damaged soundtrack with absolute silence, you will learn the exact command-line syntax required to generate a null audio source and merge it seamlessly with your video container without re-encoding the video track.


The Base Command

To insert a blank audio track into a video, you use FFmpeg's anullsrc filter to generate silent audio on the fly, and then map both the original video and the newly created silence into a final output file.

Here is the standard command to accomplish this:

ffmpeg -i input.mp4 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -c:v copy -c:a aac -shortest output.mp4

Command Breakdown

Understanding what each parameter does allows you to tweak the command to fit your specific file requirements:

  • -i input.mp4: Specifies your original source video file.
  • -f lavfi -i anullsrc=...: Invokes the Libavfilter virtual input device to generate a continuous stream of pure silence.
  • channel_layout=stereo: Sets the audio to two channels (left and right). You can change this to mono if needed.
  • sample_rate=44100: Sets the audio sample rate to 44.1 kHz, which is standard for most web videos. You can also use 48000 for standard studio quality.
  • -c:v copy: Stream copies the video track. This is crucial because it passes the video through without re-encoding it, saving you time and preserving the exact original visual quality.
  • -c:a aac: Encodes the generated silent audio into the widely compatible AAC format.
  • -shortest: Instructs FFmpeg to stop encoding as soon as the shortest input ends. Because anullsrc generates an infinite stream of silence, omitting this flag will cause the command to run forever. Using -shortest ensures the silent audio track matches the exact duration of your video.

Handling Videos that Already Have Audio

If your input video already contains an audio track that you want to completely replace with silence, you must explicitly tell FFmpeg to ignore the original audio stream. You can achieve this by adding the -map flags to manually choose your inputs:

ffmpeg -i input.mp4 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -map 0:v:0 -map 1:a:0 -c:v copy -c:a aac -shortest output.mp4

In this variation, -map 0:v:0 selects the first video stream from the first input (input.mp4), and -map 1:a:0 selects the first audio stream from the second input (the silent anullsrc). Any audio originally embedded in input.mp4 is discarded in the output file.