Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Converting FLAC to iTunes AAC (Read 27986 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Converting FLAC to iTunes AAC

I'm ready to start using iTunes AAC as the codec of choice on my iPod.  I have a rather large collection of FLAC, and need to be able to encode it all to iTunes AAC.  I've been searching all evening for an effective solution, and I came very close with iTunesEncode.exe by Otto42.  It's a great program, but, as I've read, it's been broken since iTunes 7.7.  Indeed, I tried to batch encode some of the FLACs with it in foobar2000, and more than half of them threw terribly fatal errors.  Needless to say, that's completely unacceptable. 

Anyway, I was wondering, is there another script out there that does what iTunesEncode.exe did?  I need it to either be command line (so I can batch encode with foobar2000) or have it able to batch encode by itself.

Also, if there's a standalone hack or something of the iTunes AAC codec, that would work.

Converting FLAC to iTunes AAC

Reply #1
iTunes 8.0.2: works allright.

Maybe you have to set Thread count to 1.
(File -> Properties -> Advanced -> Tools -> Converter -> Thread count)

Converting FLAC to iTunes AAC

Reply #2
I had already tried that... and I even raised the value of the -s switch (which is how long it waits in between encoding files, to minimize errors) to 10000ms.  That had no effect.  It seems random as to whether a file will encode correctly or completely fail, and it's different every time.  I am at a loss. 

On a side note, I read that Snow Leopard got HE-AAC encoding.  If that's true, then hopefully it'll be coming to iTunes soon, in which case I'd really like to get this working.  iTunes seems to make use of some of the best codecs available, and hopefully it'll be the same story for HE-AAC. 

Also, can someone tell me whether Quicktime Pro can handle large batch encodings of flac, or whether it can be used with a command line?  I hear its AAC codec is the same codec used in iTunes, and if I could use that, it would be just as good.

Converting FLAC to iTunes AAC

Reply #3
iTunes seems to make use of some of the best codecs available


Whoa.  Statements like that will get you shot around here.

One way to do this within iTunes is convert your FLACs to ALAC (using dBpoweramp) and then let iTunes transcode to AAC for you.  Not a bad idea if you want to use iTunes exclusively.

FLAC to ALAC post

And iTunes does use Quicktime to transcode.  You just can't get to all the encoder settings from within iTunes.

iTunes Plus preset reverse engineered

Converting FLAC to iTunes AAC

Reply #4
Eh... surely there must be a far less space-consuming method of doing this than converting everything to ALAC first.  Is there some kind of dBpoweramp plugin that can make use of the iTunes encoding API, like iTunesEncode (sometimes) does?  Also, is it possible, by any stretch of the imagination, to mount flac files as a CD, and then rip it from within iTunes?  That would be incredibly interesting.

Converting FLAC to iTunes AAC

Reply #5
I'm ready to start using iTunes AAC as the codec of choice on my iPod.  I have a rather large collection of FLAC, and need to be able to encode it all to iTunes AAC.  I've been searching all evening for an effective solution, and I came very close with iTunesEncode.exe by Otto42.  It's a great program, but, as I've read, it's been broken since iTunes 7.7.  Indeed, I tried to batch encode some of the FLACs with it in foobar2000, and more than half of them threw terribly fatal errors.  Needless to say, that's completely unacceptable. 

Anyway, I was wondering, is there another script out there that does what iTunesEncode.exe did?  I need it to either be command line (so I can batch encode with foobar2000) or have it able to batch encode by itself.

Also, if there's a standalone hack or something of the iTunes AAC codec, that would work.


Don't know if there is any app on windows which does batch conversion to aac (using quicktime engine), but if you have access to a mac then you can batch transcode almost any audio file formats using Max. http://sbooth.org/Max/

Converting FLAC to iTunes AAC

Reply #6
There aren't very many solutions for iTunes AAC encoding on Windows.  Your best option would be to convert your FLAC files to ALAC and then to iTunes AAC.  This would be better in the long run if you plan on using iTunes for your lossy/lossless needs anyway.  Mac OS X offers scripts and even software such as XLD and MAX that allow for FLAC to iTunes AAC encoding.  However, Windows is pretty much limited to iTunes for iTunes AAC encoding.

Converting FLAC to iTunes AAC

Reply #7
Why convert to ALAC? Doesn't iTunes support encoding of wav files? (I refuse to install iTunes  )

Edit: Thx kornchild2002, I forgot about the tags, it's late 

Converting FLAC to iTunes AAC

Reply #8
Yes, iTunes can decode/encode WAV files just fine.  However, when going from a FLAC collection to WAV files, the track tags will be lost.  Converting to ALAC will preserve the track tags during the process.  Additionally, ALAC files can be further converted using dBpowerAMP and even foobar2000 to other lossless/lossy formats.  There really is no need to use WAV unless the OP is working with 24-bit content.  Even then, dBpowerAMP is working on supporting 24-bit ALAC files in the near future.

Converting FLAC to iTunes AAC

Reply #9
Also coverting to WMA Lossless (i cannot belive i mentioned that) might work better, which has slightly better compat then ALAC . Since WMAL works on WMP, foobar2000 and can be transcoded into AAC through the iTunes first time use wizzard.
"I never thought I'd see this much candy in one mission!"

Converting FLAC to iTunes AAC

Reply #10
I'm ready to start using iTunes AAC as the codec of choice on my iPod.  I have a rather large collection of FLAC, and need to be able to encode it all to iTunes AAC.  I've been searching all evening for an effective solution, and I came very close with iTunesEncode.exe by Otto42.  It's a great program, but, as I've read, it's been broken since iTunes 7.7.  Indeed, I tried to batch encode some of the FLACs with it in foobar2000, and more than half of them threw terribly fatal errors.  Needless to say, that's completely unacceptable. 

Anyway, I was wondering, is there another script out there that does what iTunesEncode.exe did?  I need it to either be command line (so I can batch encode with foobar2000) or have it able to batch encode by itself.

Also, if there's a standalone hack or something of the iTunes AAC codec, that would work.


Unless you are absolutely 100% dead set on having iTunes AAC you will probably have an easier time converting to Nero AAC since you can very easily convert your FLAC files using dBPoweramp or Foobar without going around your nose to get to your elbow.  Try a few of your faves in Nero.  I'll wager you'll be quite happy with the sound.

Converting FLAC to iTunes AAC

Reply #11
I found a way to mount entire albums of flac as CDs.  The solution is a program called WinMount.  It's not free, but it mounts CUE files as audio CDs, and has a 15 day trial.  iTunes is then able to rip from that, which is excellent.

Converting FLAC to iTunes AAC

Reply #12
I'm ready to start using iTunes AAC as the codec of choice on my iPod.  I have a rather large collection of FLAC, and need to be able to encode it all to iTunes AAC.  I've been searching all evening for an effective solution, and I came very close with iTunesEncode.exe by Otto42.  It's a great program, but, as I've read, it's been broken since iTunes 7.7.  Indeed, I tried to batch encode some of the FLACs with it in foobar2000, and more than half of them threw terribly fatal errors.  Needless to say, that's completely unacceptable. 

Anyway, I was wondering, is there another script out there that does what iTunesEncode.exe did?  I need it to either be command line (so I can batch encode with foobar2000) or have it able to batch encode by itself.

Also, if there's a standalone hack or something of the iTunes AAC codec, that would work.

iTunesEncode.exe still works (a/o iTunes 9.0.2)
The following Windows Batch file will copy the tags & artwork from FLAC to AAC.

I also have an AppleScript for Mac (If anyone is interested, let me know)

4dos batch file (may need to edit a bit if you use the Windows shell):

Code: [Select]
@echo off
echo Set iTunes to 128VBR...
pause
for %f in (*.flac) gosub ENCODE128
exit

:ENCODE128
"C:\Program Files\FLAC\metaflac" "%f" --export-picture-to=artwork.jpg --export-tags-to=temp.txt
for /F "tokens=1,2 delims==" %%i in (temp.txt) do set %%i="%%j"
"C:\Program Files\FLAC\flac" -d "%f"
if ERRORLEVEL 1 pause
"C:\Program Files\iTunesEncode\iTunesEncode" -d -a "%@replace[%=",,%artist%]" -t "%@replace[%=",,%title%]" -l "%@replace[%=",,%album%]" -y %@instr[0,4,%@replace[%=",,%date%]] -n %@replace[%=",,%tracknumber%] -g "%@replace[%=",,%genre%]" -c "%@replace[%=",,%comment%]" -r "%@path[%@full["%f"]]artwork.jpg" -i "%@replace[.flac,.wav,%f]" -o "%@replace[.flac,.m4a,%f]"
for /F "tokens=1,2 delims==" %%i in (temp.txt) do set %%i=
del artwork.jpg temp.txt "%@replace[.flac,.wav,%f]"
return

Converting FLAC to iTunes AAC

Reply #13
Here's a bash script for the Mac (calls are made to Applescript.  To change the codex, change your settings in iTunes.)
Tags and Artwork are preserved.
Uses "find" to walk  a directory tree and execute the script (can be adapted for only one directory, see comments in script)
For example, if the FLAC's you want to convert are in ~/FLAC and this script is in ~/Scripts, then in Terminal run:
  find ~/FLAC -iname *.flac -exec ~/Scripts/FlacToACC.sh {} \;
and then all FLAC Files in the FLAC directory AND all directories below the FLAC directory will be converted
(I have a stand-alone Applescript also is anyone's interested)

Code: [Select]
#!/bin/bash
#
# Flac to AAC/m4a (or any codex supported in iTunes)
#
# Run the following find command to walk a file hierarchy and convert FLAC to AAC:
#   find <Directory> -iname *.flac -exec ~/Scripts/FlacToACC.sh {} \;
#

if [ "$1" = "" ]; then
    echo "Flac to AAC/m4a (or any codex supported in iTunes)"
    echo "Run the following find command to walk a file hierarchy and convert FLAC to AAC:"
    echo "find <Directory> -iname *.flac -exec FlacToACC.sh {} \;"
    exit
else
#
# to process only a directory, comment out the previous ' if statement ' and ' f="$1" ' below
#   and change the last line in script from 'fi to ' done '  
#
#for f in ~/Downloads/*.flac
#do
#
f="$1"
    if  [ -e "$f" -a "${f##*.}" = "flac" -o "${f##*.}" = "FLAC" ]; then
        /usr/local/bin/metaflac --export-tags-to="$TMPDIR"flactags.txt \
        --export-picture-to="$TMPDIR"artwork.png "$f"
        while read i
            do
                case "${i%%=*}" in
                    TITLE)
                        TITLE="${i#*=}";;
                    ARTIST)
                        ARTIST="${i#*=}";;
                    ALBUM)
                        ALBUM="${i#*=}";;
                    DATE)
                        DATE="${i#*=}";;
                    GENRE)
                        GENRE="${i#*=}";;
                    COMMENT)
                        COMMENT="${i#*=}";;
                    TRACKNUMBER)
                        TRACKNUMBER="${i#*=}";;
                    TRACKTOTAL)
                        TRACKTOTAL="${i#*=}";;
                esac
            done < "$TMPDIR"flactags.txt
        if [ -e "$TMPDIR"artwork.png ]; then
            ARTWORKEXISTS=Yes
        else
            ARTWORKEXISTS=No
        fi
        ORIGDIR="${f%/*}"
        FLACNAME="${f##*/}"
        M4ANAME="${FLACNAME%.*}".m4a
        WAVFILE=$"$TMPDIR""${FLACNAME%.*}".WAV
        /usr/local/bin/flac -d --output-name="$WAVFILE" "$f"
        echo -e "\nConverting ${FLACNAME%.*}.wav\nArtist:\t\t$ARTIST"
        echo -e "Album:\t\t$ALBUM\nTitle:\t\t$TITLE"
        echo -e "Track:\t\t$TRACKNUMBER\nDate:\t\t$DATE"
        echo -e "Genre:\t\t$GENRE\nAlbum Art:\t$ARTWORKEXISTS"
        echo -e "Comment:\t$COMMENT"
# +Start Applescript+
osascript <<-HereDoc
        if "$ARTWORKEXISTS" is equal to "Yes" then
                tell application "Image Events"
                launch
                set the_image to open ("$TMPDIR" & "artwork.png")
                save the_image as PICT in ("$TMPDIR" & "artwork.pict")
                close the_image
            end tell
            set FlacArtwork to read ("$TMPDIR" & "artwork.pict") from 513 as picture
        end if
        tell application "iTunes"
            set newTrack to first item of (convert POSIX file "$WAVFILE")
            set name of newTrack to "$TITLE"
            set artist of newTrack to "$ARTIST"
            set album of newTrack to "$ALBUM"
            set year of newTrack to "$DATE"
            set genre of newTrack to "$GENRE"
            set comment of newTrack to "$COMMENT"
            set track number of newTrack to "$TRACKNUMBER"
            set track count of newTrack to "$TRACKTOTAL"
            if "$ARTWORKEXISTS" is equal to "Yes" then
                try
                    set data of artwork 1 of newTrack to FlacArtwork
                end try
            end if
            set newFile to (get location of newTrack) as text
            delete newTrack
        end tell
# NOTE: File is moved to the directory of the FLAC file processed.
#        Edit if m4a needs to be moved to a different directory
#        or comment line if file is to remain in iTunes
#        (and comment "delete newTrack" 2 lines above)
    
        do shell script "mv " & (quoted form of POSIX path of newFile) & " " & quoted form of ("$ORIGDIR" & "/" & "$M4ANAME")
HereDoc
# -End Applescript-
# Cleanup:
        rm "$WAVFILE" "$TMPDIR"artwork.pict "$TMPDIR"artwork.png "$TMPDIR"flactags.txt
    fi
#done
fi

Converting FLAC to iTunes AAC

Reply #14
I'm ready to start using iTunes AAC as the codec of choice on my iPod.  I have a rather large collection of FLAC, and need to be able to encode it all to iTunes AAC.  I've been searching all evening for an effective solution, and I came very close with iTunesEncode.exe by Otto42.  It's a great program, but, as I've read, it's been broken since iTunes 7.7.  Indeed, I tried to batch encode some of the FLACs with it in foobar2000, and more than half of them threw terribly fatal errors.  Needless to say, that's completely unacceptable. 

Anyway, I was wondering, is there another script out there that does what iTunesEncode.exe did?  I need it to either be command line (so I can batch encode with foobar2000) or have it able to batch encode by itself.

Also, if there's a standalone hack or something of the iTunes AAC codec, that would work.


I've had great luck with SoundKonverter (http://kde-apps.org/content/show.php?content=29024) on Linux (which will go from .flac to .aac).  It's basically a front end for a bunch of encoders. 

Not terribly fast, but it does batch jobs on a recursive directory search (critical when each album is in a different directory), it preserved my tags, and wrote the results to my custom file and directory structure (which works as a backup if my tags are wiped out during the process).

Been pleasantly surprised with the Linux tools available for working with music files. 

Chris