Generate audio tone with FFmpeg

Create audio tones directly from the command line. FFmpeg is not just a powerful tool for converting or editing audio and video files; is a powerful multimedia framework that can generate audio tones without the need for external files. This capability is particularly useful for creating test signals, sound effects, or even chiptune music directly from the terminal.

To generate the tone in MP3 format, or another format, simply change the output file extension.

For instructions and examples see below. The source code is hosted on GitHub. Before using this tool, read the LEGAL NOTES/DISCLAIMER.


Quick Example: Generate a 440 Hz Tone for 5 Seconds

Insert all parameters

  • Wave Type: Sine
  • Frequency: 440 Hz
  • Duration: 5 seconds
  • Amplitude: 0.2
  • Output file name: output.wav

Click 'Generate'.

The tool informs you in red text if some parameters are incorrect or missing.

If all parameters are correct, you will obtain the FFmpeg code in the dedicated textarea:

ffmpeg -f lavfi -i "aevalsrc=sin(2*3.14159265*440*t)*0.2:s=44100:d=5" -c:a pcm_s16le output.wav

This command uses FFmpeg's lavfi (Libavfilter) input device to generate a sine wave. It leverages aevalsrc, an audio source that allows creating custom signals from mathematical expressions.

  • The expression sin(2*π*440*t)*0.2 defines the waveform
  • 440 in the expression sets the frequency of the sine wave in Hz
  • 0.2 in the expression sets the amplitude (volume)
  • The parameter d=5 sets the duration to 5 seconds
  • The parameter s=44100 sets the sample rate to 44.1 kHz
  • The output is saved as output.wav in uncompressed PCM format

Copy the command with the appropriate button, open a terminal or command prompt in your desired folder, paste the command, and execute it to create the file.

To generate the tone in MP3 format instead:

ffmpeg -f lavfi -i "aevalsrc=sin(2*3.14159265*440*t)*0.2:s=44100:d=5" -c:a pcm_s16le output.mp3

Notes on Output Formats:

  • .wav – Uncompressed audio format, widely supported and suitable for high-quality audio.
  • .mp3 – Compressed audio format, ideal for smaller file sizes and streaming.
  • .flac – Lossless compressed audio format, preserving original quality with reduced file size.

If you encounter any issues, need further assistance, or have specific requirements for your audio generation tasks, feel free to ask! Use the comments below or the contact form.

Comments