Ubuntu – How to use Ffmpeg to convert wma to mp3 recursively, importing from txt file

command lineconvertffmpegmp3wma

I tried different options from forums, but most of them are out of date (ffmpeg tells me about it, like with -sameq option). Im trying to understand the docs, but I can't.

I want to know how to convert recursively with ffmpeg from wma to mp3 with a for example max bitrate of 192kbps in output (but not 192 this if the original was 128kbps)

I have unless 14K wma files spread in many directories. So, I don't want to move them. Just convert them keeping filename and metadata, and delete them, if it would be possible to read the list of the files to convert from a txt file that I can create, one file per line. With this, I would manage to make the recursive search, an paste into it.

Thanks for any help. And still more thanks for any explanation about Ffmpeg.


PS: Soundconverter used to be good, but slow. Now neither one or the other. Doesn't work in 14.04 in many cases, like mine. I'm using Soundkonverter but is very slow. So, all this for preventing this recommendations. And I want to learn to use this powerful ffmpeg! and the CLI

NOTE: The script here below, was working in the first convertions. But for any reason that I cant explain, suddenly deleted the wma's in conversion, without leaving the mp3. So, I changed again to "unsolved" (to prevent occasionally problem to someone's else). The problem seems coming from avconv " Application provided invalid, non monotonically increasing dts to muxer in stream 0: 23606 >= 21720"(there are pastebins in the comments if there is someone interested in developing this bug). So, no avconv in the future.

Best Answer

This is the command I use for ffmpeg all the files in the current directory (works if names have spaces in them) on Mac where brew doesn't have avconv:

for file in *.wma; do ffmpeg -i "${file}"  -acodec libmp3lame -ab 192k "${file/.wma/.mp3}"; done