With ffmpeg, you can use the aevalsrc filter to generate silence, and then in a second command use the concat protocol to combine them losslessly:
ffmpeg -filter_complex aevalsrc=0 -t 10 10SecSilence.mp3
ffmpeg -i "concat:input.mp3|10SecSilence.mp3" -c copy output.mp3
You can control the length of silence by altering -t 10
to whatever time in seconds you would prefer. Of course, you only need to generate the silence once, then you can keep the file around and use it to pad each of the files you want to. You may also want to look up the concat demuxer - it's slightly more processor-intensive, but you may find it easier to drop into a shell script.
If you want to do it in a single command, you can use the concat filter - this will require you to re-encode your audio (since filtergraphs are incompatible with -codec copy
), so the option above will probably be best for you. But this may be useful for anyone working with raw PCM, looking to add silence to the end before encoding the audio:
ffmpeg -i input.mp3 \
-filter_complex 'aevalsrc=0::d=10[silence];[0:a][silence]concat=n=2:v=0:a=1[out]' \
-map [out] -c:a libmp3lame -q:a 2 output.mp3
Control the length of the silence by changing d=10
to whatever time (in seconds) you want. If you use this method, you may find this FFmpeg MP3 encoding guide useful.
2
I think you can accomplish something like this with mp3DirectCut (Windows only, but they say it's compatible with Linux under Wine), which avoids recompressing the sound data. If you were to go MP3 -> WAV -> MP3, you would be recompressing the already MP3 compressed data stream, losing a lot of quality on the way.
– Breakthrough – 2013-01-15T14:11:30.410Thanks. Can you run windows software via Wine from the command line? I'd prefer to avoid Wine solutions if possible as i'm reluctant to install Wine on our server. – Max Williams – 2013-01-15T14:47:07.123
Hmm, you might want to avoid the Wine route if you don't have it already. Wine itself is a fairly large download, well above a megabyte or two for a simple MP3 cut/merge tool. I'm sure there's an equivalent, Linux-native solution. If I find any additional tools, I'll be sure to let you know. – Breakthrough – 2013-01-15T16:54:18.263