Description: Simple Python Script To Transcode FLAC audio to MP3 whilst retaining tags.
Dependencies: python2, flac, lame, mutagen
Download: flactomp3.py
Source Code [Python]:
from sys import argv
from mutagen.flac import FLAC
from mutagen.easyid3 import EasyID3
from mutagen.mp3 import MP3
from os.path import splitext
from string import replace
from re import escape
import subprocess

# Set some variables based on our input flac
inbase = splitext(argv[1])[0]
inflac = inbase + '.flac'
outmp3 = inbase + '.mp3'
print "Input File: " + inflac
print "Output File: " + outmp3
# Convert flac to mp3
print "\nBegin Transcoding FLAC To MP3."

transcommand = "flac -d -o - " + escape(inflac) + " | lame -V0 - " + escape(outmp3)
transcode = subprocess.Popen( transcommand, shell=True )

# Tagging
print "\nApplying Tags to MP3.\n"
flacfile = FLAC(inflac)
mp3file = MP3(outmp3)
mp3tags = EasyID3()

for tag in flacfile.keys():
  if tag in EasyID3.valid_keys.keys():
    mp3tags[tag] = flacfile[tag]