Ubuntu 14.04: converting m4a audio to mp3

I want to convert a bunch of .m4a files that youtube-dl created to MP3 files. The files are audio only, 128kbps, AAC encoding. They play in VLC but a lot of AAC-supporting software like Sonos can’t read the .m4a files and I don’t care why, just want to convert it to the shitty 18 year old format that works everywhere.

First challenge is that ffmpeg has completely disappeared from Ubuntu 14.04. It’s been replaced with avconv. There was some nerd fight and a fork, no idea what or why or which fork is better. Sigh. Ubuntu went with the fork avtools, so I will too. (There is an ffmpeg PPA). “ffmpeg” is now “avconv”, and “ffprobe” is now “avprobe”.

sudo apt-get install libav-tools

for f in *; do
  avconv -i "$f" -metadata album="Album Title" "${f%.m4a}".mp3;
done

I realize this is all very basic, but every time I try to do any AV codec stuff I get very confused. I wasted a lot of time playing with quality options before deciding avconv was choosing a reasonable setting that I couldn’t really override, probably based on the source material. (Although apparently there’s at least two MP3 codecs buried in there being autoselected.) Also I tried using “-threads auto” to speed things up but no luck, maybe the MP3 encoder is single threaded or maybe it’s all IO bound anyway. It’s re-encoding about a megabyte a second, fast enough for my small job. GNU parallel is another solution here.

Sadly the source tracks have no useful metadata in them like song title or artist. I did throw in an album name at least.