Skip to content

Instantly share code, notes, and snippets.

@blovett
Forked from borzilleri/flac2mp3
Created November 13, 2011 02:38
Show Gist options
  • Save blovett/1361501 to your computer and use it in GitHub Desktop.
Save blovett/1361501 to your computer and use it in GitHub Desktop.
FLAC2Mp3 Converter, improved metadata handling, converts all flacs in current directory.
#!/usr/bin/ruby
# http://gist.github.com/gists/124242
filename=ARGV[0]
abort "Usage: flac2mp3 FLACFILE" if filename.nil?
`metaflac --export-tags-to=- "#{filename}"`.each_line do |s|
s.strip!
s.gsub! '"', '\"'
s.sub! '=', '="'
eval s+'"'
end
args=%Q[--tt "#{TITLE}" --ta "#{ARTIST}" --tl "#{ALBUM}" --tn "#{TRACKNUMBER}" --tg "#{GENRE}"]
basename=File.basename(filename, File.extname(filename))
puts "Encoding #{basename}.mp3"
exec %Q[flac -sdc "#{filename}" | lame --alt-preset standard #{args} - "#{basename}.mp3"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment