Sign inSign up

bigpapoo/sox

By bigpapoo

Updated over 9 years ago

Convert sound files using "sox" command: Create ephemeral container -> convert -> remove container

Image
3

2.1K

bigpapoo/sox repository overview

Description

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.

A bit of explanation

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.

Syntax

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.

Case #1: Conversion of a single sound 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 :-)

Case #2: Converting a bunch of sound files

  1. The params file: This file should be located in the same directory where your sound files are located. It's composed of exactly 3 lines:
    • Extension of source sound files (mp3, wav, aiff, ...)
    • Extension of converted sound files
    • Arguments used by the 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.

Tag summary

Content type

Image

Digest

Size

78.7 MB

Last updated

over 9 years ago

docker pull bigpapoo/sox