Convert sound files using "sox" command: Create ephemeral container -> convert -> remove container
2.1K
I needed a way to quickly and easily convert MP3 files to GSM format for use with Asterisk.
After searching for a good and free tool/service on the Web with no real success, I ended up building a Docker sox container to do the job.
You can convert a single sound file providing the complete sox command with arguments or you can create a params file to process a whole bunch of files at once.
The directory containing the source sound file(s) will be mounted as a volume on /work in the container, and this directory will be the only one used to read and write the sound files.
The following examples assume you execute the command from the directory where your source sound files are located.
You must call the mysox command in place of sox with the same arguments. mysox will perform a bunch of stuff prior to calling sox, like using the params file.
Example for converting a mp3 sound file to a 8 KHz stereo wav format:
docker run -v $(pwd):/work --rm bigpapoo/sox mysox sound.mp3 -r 8000 -c2 sound.wav
You should need to adapt only the italic bold part of the command unless you know what you do :-)
params file:
This file should be located in the same directory where your sound files are located. It's composed of exactly 3 lines:
mp3, wav, aiff, ...)sox command. You will need to specify placeholders for the source and destination files. Use @in and @out
Example for converting all mp3 sound files to gsm format:mp3 gsm @in -r 8000 -c1 @out
2 Then the command that will convert all mp3 sound files found in the current directory:
docker run -v $(pwd):/work --rm bigpapoo/sox mysox
That's it! Be aware that existing destination files will be overwritten without any warning.
Content type
Image
Digest
Size
78.7 MB
Last updated
over 9 years ago
docker pull bigpapoo/sox