IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Embedding album art in FLAC 1.1.4 images, Please help!
rohangc
post Apr 16 2007, 11:18
Post #1





Group: Members
Posts: 569
Joined: 1-December 02
From: India
Member No.: 3948



Hi. I apologize for all the trouble if this has already been asked before. I searched the forums for answers but I couldn't find a solution that matched my requirements. So here it goes...

I recently converted my entire CD collection to FLAC 1.1.4 images (with embedded CUE sheets). Unfortunately, after I finished doing this, I realized that I had forgotten to embed album art into all those images. Don't ask me how this happened, but it happened. Is it possible for me to embed album art into the "picture" blocks natively supported by v1.1.4? I did search the forums, but my directory structure and naming scheme of the jpg files prevent me from using exisiting tools.

This is how I have arranged my files:

CODE
Root_Dir\
             Artist\
                     Artist-Year-Album.flac
                     Artist-Year-Album.cue
                     Artist-Year-Album.jpg


In short, there is one cover-art jpg file for every flac file that exists in a directory. The names of the files are identical except for the extensions.

Is there a way for me to quickly and safely embed each of the jpg file into its corresponding flac image? I could have used CueProc, but that would mean completely changing the folder structure and the file naming scheme. That would be extremely time consuming and error-prone.

Please help.
Go to the top of the page
+Quote Post
gottkaiser
post Apr 16 2007, 13:02
Post #2





Group: Members
Posts: 171
Joined: 7-January 05
From: Germany
Member No.: 18891



Should be possible with MP3tag.
Go to the top of the page
+Quote Post
jcoalson
post Apr 16 2007, 16:24
Post #3


FLAC Developer


Group: Developer
Posts: 1526
Joined: 27-February 02
Member No.: 1408



that's a one-liner in bash:
CODE
for f in `find /Root_Dir -name '*.flac'`; do metaflac --import-picture-from="${f%*.flac}.jpg" $f; done
Go to the top of the page
+Quote Post
rohangc
post Apr 17 2007, 05:28
Post #4





Group: Members
Posts: 569
Joined: 1-December 02
From: India
Member No.: 3948



QUOTE (gottkaiser @ Apr 16 2007, 07:02) *
Should be possible with MP3tag.


Thanks @gottkaiser! I downloaded the program at work and I think I can use metaflac as a custom "Tool" to do this (Is that what you were hinting at?). Thanks for pointing me towards a great program!

QUOTE (jcoalson @ Apr 16 2007, 10:24) *
that's a one-liner in bash:
CODE
for f in `find /Root_Dir -name '*.flac'`; do metaflac --import-picture-from="${f%*.flac}.jpg" $f; done


Thank you very much Josh. The problem is all the files are on a windows machine at home and I don't know much about windows batch scripting. This is the reason I was looking for a Windows based program to do the job. Anyway, if all else fails, I will install linux somewhere and use bash.

By the way, will the official Fedora Core 4 build work on RedHat Enterprise WS4 (Update 3)? Please let me know

This post has been edited by rohangc: Apr 17 2007, 05:31
Go to the top of the page
+Quote Post
jcoalson
post Apr 17 2007, 06:04
Post #5


FLAC Developer


Group: Developer
Posts: 1526
Joined: 27-February 02
Member No.: 1408



no need in install linux, just install cygwin (http://cygwin.com/), that will get you a bash shell and all the other standard unix tools.
Go to the top of the page
+Quote Post
rohangc
post Apr 17 2007, 13:27
Post #6





Group: Members
Posts: 569
Joined: 1-December 02
From: India
Member No.: 3948



QUOTE (jcoalson @ Apr 17 2007, 00:04) *
no need in install linux, just install cygwin (http://cygwin.com/), that will get you a bash shell and all the other standard unix tools.


cygwin!!!! How the hell did I forget that? I must be getting really old... Thanks you very much Josh!

This post has been edited by rohangc: Apr 17 2007, 13:28
Go to the top of the page
+Quote Post
rohangc
post Apr 18 2007, 11:41
Post #7





Group: Members
Posts: 569
Joined: 1-December 02
From: India
Member No.: 3948



For what it is worth, I have put together my own version of Josh's script. It takes care of stuff like blank spaces in file names, etc. It embeds album art and then tests all the files by doing a "flac.exe -t" on all the new files. If errors occurred either during the embedding process or during the testing process, these are listed in two text files.

This is the script:

CODE
#! /bin/bash

# Set Internal Field Separator BASH built-in variable $IFS to NULL

IFS=""

# Embed album art

for i in `find ${1} -name '*.flac'`; do metaflac --import-picture-from "${i%*.flac}.jpg" ${i} 2>>${1}/errors_embed.txt; done

# Now test these files

for i in `find ${1} -name '*.flac'`; do flac -t -s -w ${i} 2>>${1}/errors_test.txt; done

# End of script


To run this script, simply do the following:

CODE
script_name <root_dir>

Note: Do NOT put a '/' after the root directory name.

This is why I love Linux! It makes everything so simple!

This post has been edited by rohangc: Apr 18 2007, 11:42
Go to the top of the page
+Quote Post
rohangc
post Apr 18 2007, 12:24
Post #8





Group: Members
Posts: 569
Joined: 1-December 02
From: India
Member No.: 3948



Looks like the above script doesn't work. It now sends the whole list of FLAC files as one single file to flac.exe.

Can anyone modify the above script to take care of blanks in file names. This can be done if $IFS can somehow be set only to newline, but I don't know how to do it.
Go to the top of the page
+Quote Post
ech3
post Apr 18 2007, 22:41
Post #9





Group: Members
Posts: 121
Joined: 13-December 01
Member No.: 632



QUOTE (rohangc @ Apr 16 2007, 10:18) *
I recently converted my entire CD collection to FLAC 1.1.4 images (with embedded CUE sheets). Unfortunately, after I finished doing this, I realized that I had forgotten to embed album art into all those images.


I'm in a similar position. I started my extract/archive project about 3 years ago and now have all my CDs as .flac files (nearly 2000 titles). At the time I didn't even consider album art, but now I'd like to include it.

But I don't know how to get the album art in the first place.

Is there any automated way of doing this?

Thanks!
Go to the top of the page
+Quote Post
tycho
post Apr 19 2007, 00:39
Post #10





Group: Members
Posts: 345
Joined: 5-August 03
Member No.: 8183



You can also make a flacpic.bat file (so you don't need bash), which also picks up "folder.jpg" if found:
CODE
@echo off
REM Embed pictures to flac files recursively.
REM It will use either <filename>.jpg where <filename>.flac is the input file, or folder.jpg.
REM It does NOT add pictures to files that already have album art!
REM Copyright Tycho (c) 2007
REM Usage: flacpic.bat [-e] [root-folder]

set e=0
if "%1"=="-e" ( set e=1 & shift )

for /R %1 %%I in (*.flac) do (
    metaflac.exe --export-picture-to=nul "%%~I" 2> nul
    if errorlevel 1 (
        echo "%%~I"
        if exist "%%~dpI%%~nI.jpg"  (
            echo.    - ADD "%%~nI.jpg"
            metaflac.exe --import-picture-from="%%~dpI%%~nI.jpg" "%%~I"
        ) else if exist "%%~dpIfolder.jpg" (
            echo.    - ADD "folder.jpg"
            metaflac.exe --import-picture-from="%%~dpIfolder.jpg" "%%~I"
        )
    ) else if %e%==1 (
        echo "%%~I"
        echo.      [has picture]
    )
)


edit : small modification so that only either folder.jpg or <filename>.jpg is added.

This post has been edited by tycho: Apr 19 2007, 01:36
Go to the top of the page
+Quote Post
rohangc
post Apr 19 2007, 05:44
Post #11





Group: Members
Posts: 569
Joined: 1-December 02
From: India
Member No.: 3948



QUOTE (tycho @ Apr 18 2007, 18:39) *
You can also make a flacpic.bat file (so you don't need bash), which also picks up "folder.jpg" if found:


Thank you very, very much Tycho! smile.gif I really appreciate your taking time out to write a script for me. But this also indicates that it is high time I learnt how to write scripts that work!

QUOTE (ech3 @ Apr 18 2007, 16:41) *
I'm in a similar position. I started my extract/archive project about 3 years ago and now have all my CDs as .flac files (nearly 2000 titles). At the time I didn't even consider album art, but now I'd like to include it.

But I don't know how to get the album art in the first place.

Is there any automated way of doing this?

Thanks!


You can try Album art downloader which does a pretty decent job. This is what I used. It does not fully automate the process though, but is your best bet at the moment.
Go to the top of the page
+Quote Post
olrac
post Nov 22 2008, 04:34
Post #12





Group: Members
Posts: 8
Joined: 29-October 08
Member No.: 61246



Can anyone explain to me how this BAT file works? I've tried so many different things but nothing works.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 25th July 2014 - 19:54