Generate Test Tones with FFmpeg Sine Filter
This article explains how to use the sine audio source
filter in FFmpeg to generate audio test tones. You will learn the basic
command structure, how to customize the frequency and duration of the
tone, and how to output the result into a standard audio file.
Basic Usage
To generate a simple sine wave test tone, you must use FFmpeg’s
Libavfilter virtual input device (-f lavfi) and specify the
sine filter as the input.
The following command generates a 1000 Hz tone that lasts for 5 seconds and saves it as a WAV file:
ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" output.wavKey Parameters of the Sine Filter
The sine filter accepts several parameters to customize
the audio output. The most commonly used parameters include:
frequency(orf): Specifies the frequency of the generated tone in Hz. The default value is 440 Hz (standard A4 pitch).duration(ord): Specifies the duration of the audio in seconds. If this parameter is omitted, FFmpeg will generate an infinite stream.sample_rate(orr): Sets the sample rate of the output audio. The default is 44100 Hz.beep_factor(orb): Enables a periodic beep. The beep frequency will be the main frequency multiplied by this factor.
Practical Examples
Generating a Standard 440 Hz Reference Tone
To generate a standard 440 Hz reference tone for 10 seconds, use the shorthand notation for the parameters:
ffmpeg -f lavfi -i "sine=f=440:d=10" reference_440.wavGenerating an Intermittent Beep
You can create a pulsing beep by using the beep_factor
parameter. This example creates an 800 Hz tone that beeps once per
second for a total of 5 seconds:
ffmpeg -f lavfi -i "sine=f=800:b=1:d=5" intermittent_beep.wavAdjusting the Tone Volume
By default, the sine filter generates audio at maximum digital volume
(0 dBFS), which can be very loud. To lower the volume, chain the
volume filter to the output:
ffmpeg -f lavfi -i "sine=f=1000:d=5,volume=0.5" quiet_tone.wavIn this command, volume=0.5 reduces the output amplitude
by 50%.