Skip to content

Instantly share code, notes, and snippets.

@bleything
Forked from mxcl/flac2mp3.md
Created August 23, 2010 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bleything/545951 to your computer and use it in GitHub Desktop.
Save bleything/545951 to your computer and use it in GitHub Desktop.
#!/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|
v=s.strip.split '=', 2
v[0].upcase!
v[1].gsub! '"', '\"'
eval %Q[#{v[0]}="#{v[1]}"];
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