Search code examples
audioffmpegopus

How to create Silent Opus Audio Files


I need silent Opus audio files range of 1 second to 60 minutes.

I found this example for wav files:

60 seconds of silent audio in WAV:

ffmpeg -ar 48000 -t 60 -f s16le -acodec pcm_s16le -ac 2 -i /dev/zero -acodec copy output.wav

60 seconds of silent audio in MP3:

ffmpeg -ar 48000 -t 60 -f s16le -acodec pcm_s16le -ac 2 -i /dev/zero -acodec libmp3lame -aq 4 output.mp3

How can I do it for opus with using ffmpeg or similar tool?


Solution

  • Using a recent build of ffmpeg, run

    ffmpeg -f lavfi -i anullsrc -ac 2 -ar 48000 -t 30 -c:a libopus file.opus
    

    You can add -vbr 0 -b:a 128k for a CBR encode.