34 lines
1.4 KiB
Markdown
34 lines
1.4 KiB
Markdown
---
|
|
title: "Mass convert WMA to MP3 using ffmpeg and ruby"
|
|
kind: article
|
|
slug: mass-convert-wma-to-mp3-using-ffmpeg-and-ruby
|
|
created_at: 2010-09-11
|
|
tags:
|
|
- 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:
|
|
|
|
:::ruby
|
|
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][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'`._
|
|
|
|
[picard]: http://musicbrainz.org/doc/MusicBrainz_Picard
|