As part of the reorganization of my home server, I am consolidating all my music files into the home server. I quickly realized that in a misguided fit of irrationality, I had gone through a phase in the past where most of my library was in the WMA format. The problem with WMA format is that not all non-Windows devices support it which meant transcoding. MP3 of course is the defacto standard for audio. I decided to convert all the WMA files in my collection to MP3. I wanted to do this on my Home Server itself that was hosting the collection so my regular machines weren’t occupied with the conversion and being kept awake. After searching a bit for tools that would help convert, I realized that the swiss knife of encoders ffmpeg could do what I wanted. I downloaded the static ffmpeg build from here and wrote this little script to do the conversion – the only tricky part was that ffmpeg reads from stdin.
find "/storage/Music" -name "*.wma" -exec /bin/bash -c ' ffmpeg=/usr/local/bin/ffmpeg for file; do dirname=$(dirname "$file") filename=$(basename "$file") filename=${filename%%.wma} outfile="$dirname/$filename.mp3" $ffmpeg -i "$file" -q:a 3 -y "$outfile" -- < /dev/null # You may want to remove the wma file here - I moved it to my boneyard dirname=${dirname##/storage/Music/} outdirname="/storage/Boneyard/Music/$dirname" [ -d "$outdirname" ] || mkdir -p "$outdirname" mv "$file" "$outdirname" done ' {} +
On Windows, you need to add an option to write ID3v2.3 headers for the metadata to convert properly. See superuser.com/a/453133/529848