How to Use the FFmpeg Sine Filter

This guide explains how to use the sine audio source filter in FFmpeg to generate custom audio test tones. You will learn the basic command syntax, how to configure parameters like frequency and duration, and how to combine the generated sine wave audio with a video stream.

The sine filter is a virtual audio source in FFmpeg’s lavfi (libavfilter) input format. It generates a pure sine wave signal, which is highly useful for testing audio equipment, creating beep sounds, or troubleshooting audio-video synchronization.

Basic Syntax

To generate a simple sine wave audio file, you must use the -f lavfi option to specify the virtual input device, followed by the sine filter configuration.

Here is the basic command to generate a 5-second audio file at the default frequency of 440 Hz (A4):

ffmpeg -f lavfi -i sine=duration=5 output.wav

Key Parameters of the Sine Filter

You can customize the audio output using the following parameters, separated by colons:

Examples of Common Use Cases

1. Generate a Specific Frequency (e.g., 1000 Hz)

To generate a standard 1000 Hz test tone for 10 seconds:

ffmpeg -f lavfi -i sine=frequency=1000:duration=10 output.wav

2. Create a Short Beep Sound

If you need a quick 0.5-second beep sound at a higher pitch (2000 Hz):

ffmpeg -f lavfi -i sine=f=2000:d=0.5 beep.mp3

3. Combine Sine Audio with a Test Video Card

You can generate a test video pattern alongside a sine wave audio tone to create a full test video file. The following command combines a testsrc video with a sine audio stream, both restricted to 10 seconds:

ffmpeg -f lavfi -i testsrc=duration=10 -f lavfi -i sine=frequency=440:duration=10 -c:v libx264 -c:a aac output.mp4