Native FLAC in iTunes/QuickTime

I feel a bit guilty about not publishing this before. But, you know, it was kind-of working, I had some time so I thought I’d re-write it in a way similar to OggImporter. Then I stopped having time. Thus, I accept those e-mails asking about native FLAC support as a deserved punishment.

The FLACImporter.component I’m writing about is actually a slightly modified importer component from Damien Drix’s QuickTime FLAC Plugin. Basically I removed the decoder part (which stopped working properly in QuickTime 7), changed codec IDs to match those found in XiphQT and made a Universal build. As it is, it parses and imports native FLAC files and then the decoding part is done by CAFLAC component, part of XiphQT.

You can find the binary files and source patch here. But read on, because it’s not all that rosy…

The component used to work when I first played with it, and it still does - in QuickTime Player (and a number of other QuickTime-based apps) that is. It doesn’t have all the functionality of the OggImporter, and performance could be better, too. But it works, it plays the FLAC files.

But… you guessed it right: iTunes. iTunes is something else. On my machine iTunes plays native FLAC files fine, yes, but they need to be in iTunes Library already. That is - it won’t (easily) accept new files with the .flac extension.

During my tests I discovered, however, that iTunes will accept .flac files if you set their FSTypeCode to something popular and openable with QuickTime, like ‘MooV’ (original FSType of .mov QuickTime Movie files) or… ‘OggS’! Which is the FSType used by OggImporter component to denote .ogg files. And that’s quite an intriguing discovery, since both components use nearly perfectly identical steps to register with the OS! How come?! To test, I created a copy of OggImporter that only uses different FSType and file extensions - and it doesn’t work. So, how’s that? Does iTunes have the ‘.ogg’ and ‘OggS’ hardcoded somewhere? Is my machine’s OS going slightly crazy? Am I missing something? I’ll try to investigate that…

But for now, the summary. The FLACImporter should work in QuickTime (you’ll need the XiphQT package, as well). It should work in iTunes, but there may be problems with adding .flac files to your library. If you can’t add them, and don’t mind a bit of cheating, you can set the FSType of you FLAC files to ‘OggS’ (or ‘MooV’, but ‘OggS’ should work). You can set it with SetFile tool from the developer packages (/Developer/Tools/SetFile). On the FLACImporter page you can also find a simple python script I wrote that should work on a machine without dev packages installed. Setting slightly-not-true FSType should be harmless and is reversible (set FSType to 0). In case I/someone finds a better solution…

Note on the Intel part of the binary: it’s untested. Let me know if doesn’t work. No Win32 binaries either, since I don’t have a machine to compile it at the moment.

So, is it working for you? How about the strange iTunes behaviour - anybody able to shed some light on the puzzle?

56 comments on “Native FLAC in iTunes/QuickTime”

  1. The Lossless Audio Blog » Native FLAC in iTunes/QuickTime:

    […] *We are working on a Downloads & Utilities section to add to The Lossless Audio Blog to compile many of these plugins and utilities into one spot. Read More…   […]


  2. Santi wrote:

    Hey! i’ve been waiting for more than a year now!!!!!
    Looks better now. And for the Banner pic, looks like youdidn’t bought that
    f1.2 18mm lens :D

    I’ll check the feeds now on!


  3. Arek wrote:

    Santi, that’s some surprise!! :D
    Thanks. No, not 18mm, but… more about that once I have my photo section running. ;)

    Your diversion looks better since I last checked, and has some really good photos, too. Keep it coming!


  4. nick wrote:

    i have installed both xiphqt and flac import and can’t get flac files to even play in itunes (by attempting to open flac files from in finder with itunes) let alone import them into itunes library. could someone help me out with getting this set up?

    thanks

    nick


  5. Neil wrote:

    I’m having the same hassles as Nick.


  6. Arek wrote:

    I added a simple drag’n'drop tool to set FSType on (FLAC) files - that should allow you to add/play the files in iTunes. Try these three steps (after installing the components):

    1. Get the ‘Set OggS’ .dmg package and open it.
    2. Select your FLAC files in Finder and drop them on the ‘Set OggS’ application.
    3. You should be able to play those files in iTunes.


  7. nick wrote:

    thanks arek

    i managed to apply the ’set oggs’ to all my music collection in less than 10 mins (17,000) doing 1,000 at a time, as it wasn’t happy doing all at once, and now i can import and play these files.

    early indications suggest a couple of hitches though:

    (i) can’t seem to apply artwork to files - i get the message ‘album art not modifiable’

    (ii) ‘my rating’ and ‘year’ tag info isn’t getting through to itunes.

    now a couple of questions:

    (i) is it possible to encode to flac from cd straight into itunes?

    (ii) can flac files be converted to mp3 and transferred to my ipod?

    thanks for your help

    nick


  8. shanecavanaugh wrote:

    In a previous release of iTunes, there was an “ogg” icon in the Resources folder of the iTunes’ package, and I’ve heard a rumor that FLAC will be supported natively in Leopard, so maybe Ogg Vorbis will be as well.


  9. Brian Gavin wrote:

    Arek,

    Your method works perfectly, as described. I note that “track number” and “year” do not carry into iTunes. I wonddr if there is a simple fix?

    Does anyone know of a Mac musoc libraary that handles flac files and has UPnP or DAAP capability?

    BG


  10. Jeroenimo wrote:

    Awesome, just one thing wich is quite sad, it refuses to play over the Airport express Airtunes :-( Works great on the “normal” speakers or headphones.

    By the way I’m on OSX … not on a PC


  11. Pictures and Code » Blog Archive » FLAC and OGG support for iTunes - import and play:

    […] The next day i found this nice blog post about adding ogg and flac support to iTunes. […]


  12. John wrote:

    any way to do this with a pc?


  13. ruumis wrote:

    Can you please compile a Win32 version at your earliest convenience? Thanks so much for your efforts.

    Rumors abound regarding supposed native FLAC support in Leopard, which would mean that a FLAC-enabled iTunes update wouldn’t be far behind. I guess it’s just a matter of time. It seems so trivially simple, when you consider that other players have supported it natively for ages…


  14. MArk Fleming wrote:

    Note: iTunes info.plist contains valid type information supported:

    ie. QuickTime movies is listed as:
    ….

    CFBundleTypeExtensions

    mov

    CFBundleTypeIconFile
    iTunes-movie.icns
    CFBundleTypeName
    Movie File
    CFBundleTypeOSTypes

    MooV

    CFBundleTypeRole
    Viewer
    LSIsAppleDefaultForType
    No


    but ‘OggS’ and extension .ogg is not found. is not listed, so it looks like iTune may not used this for list of valid type it can read! I have not try to add FLAC fle type / extension to this info.plist file inside itunes to see if thats all that needed. This would save change file types.

    NOTE: Finder and Launch services use this information to do drag and drop and selecting which application can open files. Open with menu…


  15. McMuad wrote:

    FLAC in iTunes playing on AirPort Express Airtunes

    As Jeroenimo I couldn’t play my FLAC collection with Airtunes. Then I found AirFoil (CA$ 30) which can redirect any software audio output to an airport express including iTunes output. I gave a try and it works great.

    1. Change FLAC file FSType to OggS (’SetFile -t OggS’)

    2. Add FLAC file to iTunes library

    3. Quit iTunes

    4. Run AirFoil and set it to ouput iTunes to your Airport Express

    5. Run iTunes and play your FLAC file

    6. Listen to the wonderful lossless sound on your HiFi system…


  16. Aaron wrote:

    Works, but even with my 2.16ghz 2gb MacBook Pro, iTunes runs the audio files quite slowly, when I’m on a randomization and I hit my .flac files, they take several seconds to load up and play. Hopefully in the future the lag won’t be such a problem.


  17. Russ wrote:

    For me at least, iTunes will add artwork automatically if:
    + You are signed into your iTunes account (you do have one don’t you?)
    + The album is available in iTunes
    You can also choose get artwork manually. If not - no album artwork and the ‘Album art not modifiable. I can’t see a way of getting iTunes to accept artwork for files not in the iTunes store. I’ve tried a few ways but no luck. Does anybody have any ideas?

    Russ


  18. eli sarver wrote:

    It worked for me too! This makes one less step when a CD is stubborn enough to require Max paranoia or EAC on windows.


  19. 1 33 FLAC and OGG support for iTunes - import and play 34:

    […] The next day i found this nice blog post about adding ogg and flac support to iTunes. […]


  20. Yogesh wrote:

    I got the above component compiled for Win32..
    Please email me yogesh.kini@gmail.com if you guys want the binary or the source.
    The binary suffers the same problem stated above doesn’t open with itunes.


  21. terranav » Barelyfocused » Native FLAC in iTunes/QuickTime:

    […] link […]


  22. shepherd wrote:

    i can’t get “set oggs” to work for some reason. i can’t drag my flac files into it.
    help please.


  23. shepherd wrote:

    sorry about that.
    now it works!!!!!
    thanx this is great!


  24. Joshua Bloom wrote:

    I’ve recently switched to the Mac and would love iTunes Flac support.

    For now though I’m probably going to keep my music collection running on Windows with MediaMonkey which will rip CDs into flac, and sync them to mobile devices, auto converting to mp3 as needed. Its a nice solution.

    Don’t forget to check out Songbird as that can support flac as well.


  25. Kris Tilford wrote:

    Worked great after I used the Set OggS. I wondered if the files could be unset after they were imported, but when I used the unset to the imported file it would no longer play, so this means they’ll always say Kind: QuickTime movie file I guess?

    Also, the playback is a little flaky, if I’m editing other files the playback will often stop for a tiny bit.

    The album cover art doesn’t hold on the flac files, but a single mp3 file can serve to hold the cover art.


  26. Tom wrote:

    Any word on compatabiliity, support etc now Leopard’s out?


  27. Chad wrote:

    I’m running Leopard, and listening to flacs with itunes. (I still had to use the Set OggS script–so nothing seems to have changed.) This is SO SO CLOSE to a usable solution for me, but the track number thing kills it. I can’t listen to albums this way–they always sort by track name. Any news on fixing the track number thing? Also, where would one put a feature request for Apple to support FLAC files directly? Geez, 99% of the code they need is sitting right here. There must be some enthusiasts on the iTunes team…


  28. Arek wrote:

    I’m glad XiphQT is running at all on Leopard. I don’t have access to 10.5 yet, so I’m not able to see myself if anything improved, e.g. the promised access to iTunes metadata types from QuickTime API. So that will have to wait a bit.

    As for the feature request - FLAC has a page dedicated to the subject, see: http://flac.sourceforge.net/itunes.html.


  29. rob wrote:

    okay so get toast, drag your flac files on an Audio CD , then export Apple Lossless no CPU issues takes 10min at most for big album

    works great


  30. Beechwoods wrote:

    Really pleased that this is still ‘kind of’ working in Leopard as I used it all the time in Tiger. What doesn’t seem to work though is the finder preview - which was what I really liked in Tiger. Being able to ’sample’ a FLAC file directly in the finder. Is this just my installation, or has Leopard broken the finder preview for native FLAC playback, and if so, is there likely to be a review of the patch to get round it?

    Brilliant work, the way!


  31. Beechwoods wrote:

    I should say that changing the FSType to ‘MooV’ does get the finder preview working, though using the ‘OggS’ type doesn’t… Tiger didn’t require the FSType fix to preview native FLAC files…

    Cheers :-)


  32. Idetrorce wrote:

    very interesting, but I don’t agree with you
    Idetrorce


  33. kondooit wrote:

    As for the suggestions to convert to Apple Lossless, don’t bother if you are a real audio enthusiast. Apple Lossless is not lossless. Compare waveforms of original to encoded and see for yourself.


  34. powerlin518 wrote:

    ok,thanks!


  35. kansei wrote:

    I think the set oggs python script would be 100x better if I could drag my “music” folder to it. My stuff is all in an artist name \ album title \ file directory hierarchy and it will take ages to go through all that. Plus the fact that I have to manually set track number for each? I’ll have to take a look at the code to see if that’s an easy fix (I know python).


  36. Arne wrote:

    “Apple Lossless is not lossless. Compare waveforms of original to encoded and see for yourself.”

    I did, with an album of 13 tracks. No sample differences whatsoever. My guess is that you incorrectly compared the result of two rips (ripping an audio CD is not deterministic), or the entire containers (e.g. WAV) instead of just the sample data. Containers were indeed not identical - MD5 sums differed - but that’s completely irrelevant.


  37. A random weblog but it's mine:

    fluke: itunes and FLAC…

    I sometimes have flac files, I like it because as its names says it (Free Lossless Audio Codec), it’s lossless and it’s free. I just discovered a piece of software that bundles and automates the loading FLAC’s in itunes. It’s co…


  38. fornetti wrote:

    I do not believe this


  39. Flüge wrote:

    I just heard about FLAC a couple of weeks ago and decided to give it a try. A friend of mine claimed it to be awesome. Well I really had some problems at the beginning, but it indeed is great! I recommend everybody to give it a try in order to enjoy a boundless-media experience. Thanks for your help here.


  40. Jeremiah wrote:

    I would like to second the request for track number support or even just to change the code so it doesn’t remove the numerical data from the song title(then the songs would be in order). If anyone has come up with a work around for this please contact me.


  41. justin wrote:

    i’d like the 3rd the request for the track numbers. I’d be willing to pay for development of this features. I don’t understand why the title and artist fields are honored, but the track number is not. If there is any solution please let me know or suggestions on how we can get this fixed. I like using itunes, but I have over 20GB of songs in ogg and can not convert.


  42. Alexwebmaster wrote:

    Hello webmaster
    I would like to share with you a link to your site
    write me here preonrelt@mail.ru


  43. The Mac .flac iTunes Blues | The InkWells:

    […] http://barelyfocused.net/blog/2006/10/12/native-flac-in-itunesquicktime/ […]


  44. JamesIsIn wrote:

    I am involved in a similar advanture:

    http://www.soundunreason.com/InkWell/?p=928

    The problem I am encountering is that I am trying to play flacs across a DAAP share, and iTunes sees the flacs correctly but doesn’t seem interested in playing them. Can you offer any insight?


  45. Want to be able to play FLAC files - Smart Car of America Forums:

    […] just get an ipod. here is a c&p i did on flac on any ipod It takes a quicktime plug-in for FLACs, as well as a component file, but its real easy. With everything installed its a two step process. You drop the files on the app (takes like 2 seconds), and then drop it in itunes (normal import speed). this is from the readme (for macs). if you have a [COLOR=green ! important][COLOR=green ! important]pc[/color][/color], just go to the first url, and read that readme for further directions. 1. Make sure you have XiphQT installed. (Xiph.Org: QuickTime Components :: Downloads) 2. Make sure you have FLACImport.component installed. (Arek @ Xiph.Org: FLAC Importer) 3. In Finder, select your FLAC files. 4. Drop the selected files on ‘Set OggS’ app. 5. You should be able to add the selected files to iTunes (drag’n'drop, or from menu). If you need to clear the OggS type on your FLAC files, drop them on the ‘Clear OggS’ app. Helpful links Putting Vorbis and FLAC back in iTunes | Root | Macworld http://barelyfocused.net/blog/2006/10/12…tunesquicktime/ […]


  46. Thomas , Zauberer Zauberkünstler wrote:

    Hi there,
    I found great ideas and discussing on your Web site.
    Well done ! Thanks for that and keep on doing
    Greetings from germany , Thomas


  47. Gummistiefel wrote:

    It complements XiphQT with native FLAC importing until a new importer gets written as a part of XiphQT.

    I haven’t tested it on Intel platform, but it works on PPC with QuickTime and a couple of other QuickTime apps. Some special steps are necessary for iTunes, but works too. See my comments/rants on this for some more info.

    All feedback (especially - does it work on Intel Macs?) is welcome.


  48. SEO wrote:

    ..works great. Trying to test it on Intel MACS now…


  49. Strom sparen wrote:

    Don´t need to test that, SEO! It works fine on Intel Macs, no problem! Best regards from germany, Marco


  50. xtcommerce templates wrote:

    Works great on the normal speakers or headphones. Thanks for this cool tip.


  51. RichardE wrote:

    Anyone tried this with QuickTime X in Snow Leopard? Any news on this feature being integrated into XiphQT?


  52. ils wrote:

    It is very difficult to do this with Snow Leopard - Apples DRM wouldn’t let you out, but with a nice linux system you can do it :-)


  53. Wasserbetten wrote:

    Works really great! Thanks for the tip man!


  54. Ballonkünstler wrote:

    Yes, it works ! Thanks for sharing your knowledge.


  55. Etikettendrucker wrote:

    Thanks for that posting. It works.


  56. Etikettendrucker wrote:

    As for the suggestions to convert to Apple Lossless, don’t bother if you are a real audio enthusiast. Apple Lossless is not lossless. Compare waveforms of original to encoded and see for yourself.