8

Mass convert WMA to MP3 using ffmpeg and ruby

 3 years ago
source link: https://www.devroom.io/2010/09/11/mass-convert-wma-to-mp3-using-ffmpeg-and-ruby/?utm_campaign=Feed%3A+ariejan+%28ariejan%7Cdevroom.io%29
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Mass convert WMA to MP3 using ffmpeg and ruby

Posted: 2010-09-11 - Last updated: 2019-06-05

Tagged audio mp3 wma music ffmpeg

Today I found myself in a situation where I have a few (200+) WMA audio files. Due to personal preference I want MP3, not WMA. So, let’s convert that lot.

What I want to do is convert all those WMA files to constant bitrate 192kbps, stereo mp3 files. (In my case, the WMA files have the required quality to use this settings). ~ The first tool you need is ffmpeg. If you’re on Mac, simple run brew install ffmpeg. The second tool is irb or _Interactive Ruby.

With ffmpeg setup and in your path, create a directory and stuff you WMA’s there. Then open irb and run the following Ruby command:

ext = ".wma"
Dir.glob("*#{ext}").each {|f| m = f.gsub(ext, '.mp3'); `ffmpeg -i '#{f}' -ab 192k -ac 2 -ar 44100 '#{m}'` }

When done, you’ll find the WMA files converted to MP3 (having the same filename, except for the extention).

Happy transcoding!

Note: If you need to add ID3 tags to your files, I can highly recommend MusicBrainz Picard. It can fingerprint your music and find the proper data online. It’s free!

Update: Added a separte ext variable, this works great for converting FLAC to MP3 as well! Just use ext = '.flac'.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK