Fix for those wanting JPEGs in FLAC files

Ask questions and get answers on how to make Max behave.
Mike1
Posts: 201
Joined: Thu Sep 21, 2006 3:55 pm

Fix for those wanting JPEGs in FLAC files

Post by Mike1 » Wed Feb 25, 2009 12:09 pm

It seems there's at least one FLAC player that needs the embedded cover art in a FLAC to be in JPEG format.

Maybe anyone who needs that could submit it as a feature request here, so that Stephen could consider it:

http://trac.sbooth.org/Max/

Anyway, what to do if you need JPEGs in there ...

Here's what I've found. I thought of ripping/encoding in Max but tagging in a separate application.

I first looked at Media Rage but found that although Media Rage would put a JPEG into a FLAC file it could only do so one file at a time, which is a bit limiting. It also crashed every time I did it. That doesn't seem promising for two reasons. But that might work - I don't know whether it's doing it correctly WRT the spec, or whether any particular players can or can't see the cover art when MR has added it.

I looked for other taggers. I found little. There's something called jaikoz - it's not clear to me whether it does that or not. The application seems to be tied to MusicBrainz, which would put me off.

I looked for a commandline tagger. Success! And it's free as in beer and open source. It's metaflac, which is part of the official FLAC tools. You can get a Mac installer that's distributed in a dmg here:

http://sourceforge.net/project/showfile ... e_id=32318

How to use it. See here:

http://flac.sourceforge.net/documentati ... aflac.html

And here:

http://flac.sourceforge.net/documentati ... ns_picture

Specifically you want (from the first link):

Code: Select all

--import-picture-from={FILENAME|SPECIFICATION}
And (from the second):

Code: Select all

 The format of SPECIFICATION is

  [TYPE]|[MIME-TYPE]|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE
I guess it's nice to have all those options, although it does over-complicate matters. But, it seems, if you just leave 'em all out defaults are assumed.



All in all, I don't think this is too fiddly to be practicable. Don't forget that in OS X's Terminal you can pass on some of the typing that would be necessary on other Unix-based platforms. If you drag and drop a file or folder in an open Finder window, the OS automatically completes the path for you - and correctly escapes the spaces.

OK. So all you do is run the FLAC installer. Now you open Terminal. Terminal opens with your Home area as your current working directory. You could use cd to move to where the music files and cover-art file is - for example:

Code: Select all

cd /Users/mike/Music/Sting/Songs\ from\ the\ Labyrinth
Just type cd at the prompt and drag and drop the directory in the open window.

Let's say your cover art is called cover.jpg and is in your current working directory. To import the artwork into a file, call metaflac from the commandline. At the prompt type:

Code: Select all

metaflac --import-picture-from=cover.jpg music_file.flac
To give an actual example with the file 01 Walsingham.flac:

Code: Select all

metaflac --import-picture-from=cover.jpg 01\ Walsingham.flac
I tried it. It seems to work.

It should also work with multiple music files. In that case, at the prompt type:

Code: Select all

metaflac --import-picture-from=cover.jpg
type a space after that, then highlight all the music files and drag-and-drop them in the Terminal window. Return to Terminal and hit "Return".

User avatar
sbooth
Site Admin
Posts: 2445
Joined: Fri Dec 23, 2005 7:45 am
Location: USA
Contact:

Re: Fix for those wanting JPEGs in FLAC files

Post by sbooth » Wed Feb 25, 2009 4:03 pm

This is an interesting discussion. The change in source code required to embed JPEGs in FLAC is trivial- in FLACEncoderTask.m change lines 246-251 from

Code: Select all

			imageData	= [bitmapRep representationUsingType:NSPNGFileType properties:nil]; 			
			
			// Add the image data to the metadata block
 			block->data.picture.type		= FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER;

			result = FLAC__metadata_object_picture_set_mime_type(block, "image/png", YES);
to

Code: Select all

			imageData	= [bitmapRep representationUsingType:NSJPEGFileType properties:nil]; 			
			
			// Add the image data to the metadata block
 			block->data.picture.type		= FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER;

			result = FLAC__metadata_object_picture_set_mime_type(block, "image/jpeg", YES);

Mike1
Posts: 201
Joined: Thu Sep 21, 2006 3:55 pm

Re: Fix for those wanting JPEGs in FLAC files

Post by Mike1 » Wed Feb 25, 2009 7:25 pm

sbooth wrote:This is an interesting discussion.
Interesting in rather a horrifying way for you, you knowing what you did I should think.

It was kind of interesting for me to look into, but what a lot of fuss when it can be accomplished as you show!

TomBK
Posts: 14
Joined: Mon Feb 23, 2009 8:31 pm

Re: Fix for those wanting JPEGs in FLAC files

Post by TomBK » Thu Feb 26, 2009 12:04 am

I'm absolutely speechless...the wealth of information that is available in forums like this is "horrifying" :D This really has enlightened me, thanks Mike :D (Have a look at these forums Mike, http://forums.linn.co.uk/bb/index.php they are full of fun posts :D I think you wil find some of them intersting.

Couldn't get it to work on multiple files, but never mind - point proven :mrgreen: Twonky now accepts and shows embedded album art if it's jpg instead of png. It even works without the Folder.jpg file residing in the album/music folder - as long as it's embedded. Had a few albums that just wouldn't show no matter what I did - but now with jpg's embedded they all show album art.

sbooth, being a bit thick but knowing I wanted tech information :wink: , by source code do you mean changes that should be made to Max or is this something that can be made in the Terminal window as well?
sbooth wrote:This is an interesting discussion. The change in source code required to embed JPEGs in FLAC is trivial- in FLACEncoderTask.m change lines 246-251 from

Code: Select all

			imageData	= [bitmapRep representationUsingType:NSPNGFileType properties:nil]; 			
			
			// Add the image data to the metadata block
 			block->data.picture.type		= FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER;

			result = FLAC__metadata_object_picture_set_mime_type(block, "image/png", YES);
to

Code: Select all

			imageData	= [bitmapRep representationUsingType:NSJPEGFileType properties:nil]; 			
			
			// Add the image data to the metadata block
 			block->data.picture.type		= FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER;

			result = FLAC__metadata_object_picture_set_mime_type(block, "image/jpeg", YES);
And now we're at it, are these changes that could be incorporated in RIP whenever that shows up? :wink:

PS: Just got the multiple file thing running, sweet :D My first attempt with using the Terminal so kind of satisfied with my self. But then I had a good teacher :wink:
ADS/D/Cara1 • KK/1/D • 5103 • 2 Solos • 242s/quinwired k600+k400 • Center: Klout/Ekwal aktiv • Linn silver ics • Readynas Duo/Twonky 5.0.68
Bits & bobs listed elsewhere...;-) But I'm on a Mac...

RonaldPR
Posts: 433
Joined: Tue May 30, 2006 8:27 am
Location: Amsterdam, Netherlands

Re: Fix for those wanting JPEGs in FLAC files

Post by RonaldPR » Thu Feb 26, 2009 10:49 am

TomBK wrote:by source code do you mean changes that should be made to Max or is this something that can be made in the Terminal window as well?
The source code is what programmers work on, not the ready build application. You can download the Max 0.8.1 source from Max web page http://sbooth.org/Max , but you will need to build the Max application yourself from the source. Considering that you do not know what "source code" is, I suppose that this may be beyond your computer capabilities, but if you want to try, there are other participants in this forum who did it and who may be able to help.

Mike1
Posts: 201
Joined: Thu Sep 21, 2006 3:55 pm

Re: Fix for those wanting JPEGs in FLAC files

Post by Mike1 » Thu Feb 26, 2009 10:51 am

TomBK wrote:(Have a look at these forums Mike, http://forums.linn.co.uk/bb/index.php they are full of fun posts :D I think you wil find some of them intersting.
Thanks for the link, Tom. I've got one or two Linn CDs. (No Linn equipment, though - it's too expensive for me!) So I can imagine their forums would be interesting.

I think I can see exactly what Stephen means, although I would never have even tried to look at source code not being a programmer.

The source code for Max is available as well as its object code. That's to say you can get the code that the finished program is made from. So anyone can grab it, alter it as they please, and compile it into a working program. This is what the Free Software Movement people mean by "Freedom 1":
The freedom to study how the program works, and adapt it to your needs (freedom 1). Access to the source code is a precondition for this.
Here are the files:

http://files.sbooth.org/

You see the one Max-0.8.1-source.tar.bz2 ?

If you download that and unzip it, you'll find a lot of source-code files. Inside the main directory (Max-0.8.1-source) there's a directory called "Tasks"; inside that there's one called "EncoderTasks"; and inside that there's a file called "FLACEncoderTask.m".

Anyone who's got Apple's Developer Tools installed could alter that and then build the application with Xcode.app. Apple makes the Developer Tools available free but doesn't install them by default. They should be on one or other of the install DVDs in a separate folder somewhere. The folder might be called "Xcode Tools" or something like that.

Once the application is built that way it just automatically uses JPEGs instead of PNGs.

TomBK
Posts: 14
Joined: Mon Feb 23, 2009 8:31 pm

Re: Fix for those wanting JPEGs in FLAC files

Post by TomBK » Fri Feb 27, 2009 7:13 pm

Hi Mike (and sbooth)

Thank you for believing in me :wink:

And to the rest of you please don't waste your time on this if you don't find it as funny as I do :)

Ok, doing the syntax alteration in the FLACEncoderTask.m file is easy... from png to jpeg in 2 places .

But when building, and this is where I need help in many ways... I'm not sure which file I should build from and how to load it into Xcode. The " Max.xcodeproj"? or maybe the Targets "Max"?

The image I have posted is what I get when building from " Max.xcodeproj" but without having done anything to any of the files(well, except decompressing :wink: ). Just did the Open...thing in Xcode. (Tried this because I couldn't see any similarities between these 14 errors and 2 warnings and the text alterations I had done).

If someone could give me a hint of what's going wrong/what I'm doing wrong I would highly appreciate it. Have done some FAQ and how to reading in the Xcode-manual but not found what I need.

And again, please don't waste your spare time on this... :P I'm not... :mrgreen:

Thanks... Tom
Attachments
Billede 3.png
ADS/D/Cara1 • KK/1/D • 5103 • 2 Solos • 242s/quinwired k600+k400 • Center: Klout/Ekwal aktiv • Linn silver ics • Readynas Duo/Twonky 5.0.68
Bits & bobs listed elsewhere...;-) But I'm on a Mac...


TomBK
Posts: 14
Joined: Mon Feb 23, 2009 8:31 pm

Re: Fix for those wanting JPEGs in FLAC files

Post by TomBK » Sat Feb 28, 2009 8:21 am

Thanks sbooth

Interesting stuff... will have a look at this and then probably return within a couple of days/weeks :lol: with some more ridiculous questions 8)
ADS/D/Cara1 • KK/1/D • 5103 • 2 Solos • 242s/quinwired k600+k400 • Center: Klout/Ekwal aktiv • Linn silver ics • Readynas Duo/Twonky 5.0.68
Bits & bobs listed elsewhere...;-) But I'm on a Mac...

TomBK
Posts: 14
Joined: Mon Feb 23, 2009 8:31 pm

Re: Fix for those wanting JPEGs in FLAC files

Post by TomBK » Sun Mar 01, 2009 3:16 pm

Mike sbooth...

I think I love you :P

This is fun, I actually think I'm Einstein at the moment 8) No of course not, this is just a breakthrough for me, I know you guys consider this trivial...

Have succeeded in making the build with Max embedding and downloading jpegs and have ripped a cd with it having showed in both Twonky and Songbook, success!

One question though:

I have ended up with two folders:

Max.build
Release

The Release folder containing the application but is this it? Is this the finished application that I should put straight into the Applications folder or is there more to the finishing part of this?

Cheers Tom
ADS/D/Cara1 • KK/1/D • 5103 • 2 Solos • 242s/quinwired k600+k400 • Center: Klout/Ekwal aktiv • Linn silver ics • Readynas Duo/Twonky 5.0.68
Bits & bobs listed elsewhere...;-) But I'm on a Mac...

User avatar
sbooth
Site Admin
Posts: 2445
Joined: Fri Dec 23, 2005 7:45 am
Location: USA
Contact:

Re: Fix for those wanting JPEGs in FLAC files

Post by sbooth » Sun Mar 01, 2009 9:14 pm

No, moving Max.app from the Release folder is it!

TomBK
Posts: 14
Joined: Mon Feb 23, 2009 8:31 pm

Re: Fix for those wanting JPEGs in FLAC files

Post by TomBK » Sun Mar 01, 2009 9:33 pm

sbooth wrote:No, moving Max.app from the Release folder is it!
Thanks a lot for all your help, this has been very interesting, doubt it if I will ever do stuff like this again so was great fun trying out :D
ADS/D/Cara1 • KK/1/D • 5103 • 2 Solos • 242s/quinwired k600+k400 • Center: Klout/Ekwal aktiv • Linn silver ics • Readynas Duo/Twonky 5.0.68
Bits & bobs listed elsewhere...;-) But I'm on a Mac...

cenk
Posts: 13
Joined: Sat Nov 29, 2008 2:05 pm

Re: Fix for those wanting JPEGs in FLAC files

Post by cenk » Mon May 18, 2009 7:45 pm

really good discussions... Can you help to a programming illiterate guy, like myself, on how to save the coverart files with .jpg extension (rather than .jpeg) for FLAC files in the album folder... It really would be nice to have this option in the preferences menu as many DLNA's do not see .jpeg but only see .jpg files.

User avatar
sbooth
Site Admin
Posts: 2445
Joined: Fri Dec 23, 2005 7:45 am
Location: USA
Contact:

Re: Fix for those wanting JPEGs in FLAC files

Post by sbooth » Tue May 19, 2009 2:26 am

Yes, in EncoderTask.m, line 213, change @"jpeg" to @"jpg". That should do the trick!

RonaldPR
Posts: 433
Joined: Tue May 30, 2006 8:27 am
Location: Amsterdam, Netherlands

Re: Fix for those wanting JPEGs in FLAC files

Post by RonaldPR » Tue May 19, 2009 8:52 am

Hm, is this EncoderTask.m a file in the source? Does not help a "programming illiterate guy" much.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests