-
-
Save msoap/2193212 to your computer and use it in GitHub Desktop.
Simplest functional FLAC to MP3 converter script you can make
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# http://gist.github.com/gists/124242 | |
# Deps: brew install flac lame | |
filename = ARGV[0] | |
abort "Usage: flac2mp3 FLACFILE" if filename.nil? | |
map = {"TITLE" => "--tt", "ARTIST" => "--ta", "ALBUM" => "--tl", "TRACKNUMBER" => "--tn", "GENRE" => "--tg", "DATE" => "--ty"} | |
args = "" | |
`metaflac --export-tags-to=- "#{filename}"`.each_line do |line| | |
key, value = line.strip.split('=', 2) | |
key.upcase! | |
args << %Q{#{map[key]} "#{value.gsub('"', '\"')}" } if map[key] | |
end | |
basename = File.basename(filename, File.extname(filename)) | |
puts "Encoding #{basename}.mp3" | |
exec %Q[flac -sdc "#{filename}" | lame -V2 #{args} - "#{basename}.mp3"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment