Saturday, August 31, 2013

One-liner to convert any music file to mp3

On Debian 7 ffmpeg is not installed any more as it comes with its successor avconv.
Therefore it is enough to write a small bash for loop which takes any *.wma file of the folder and starts the conversion. The output file will then have the file extension replaced to mp3. Done!
The result looks like this:
for f in *.wma; do avconv -i "$f" -ab 192k "${f%.wma}.mp3"; done
However, you can replace the two occurrences of *.wma with any other music file format you want to convert from (eg: *.flac, *.aac, *.wav,...). Keep in mind that you need to have the right gstreamer plugin installed to encode and decode the desired formats.