How to generate a sine wave with ffmpeg?
To generate a 1000 Hz signal for 5 seconds duration use this:
ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" test.wav
You can add -c:a pcm_s16le
:
ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" -c:a pcm_s16le test.wav
To also set the sampling rate to 48 KHz:
ffmpeg -f lavfi -i "sine=frequency=1000:sample_rate=48000:duration=5" -c:a pcm_s16le test.wav
Apologies for necro-ing this, but in the event that someone from the future comes looking for this, if you wanted to do this in stereo, you would do the following:
ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" -ac 2 output.wav
You could also use -filter_complex
with amerge
:
ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" -filter_complex "[0:a][0:a]amerge=inputs=2[aout]" -map "[aout]" output.wav