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: Embedding album art in FLAC 1.1.4 images (Read 15274 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Embedding album art in FLAC 1.1.4 images

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: [Select]
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.

Embedding album art in FLAC 1.1.4 images

Reply #1
Should be possible with MP3tag.

Embedding album art in FLAC 1.1.4 images

Reply #2
that's a one-liner in bash:
Code: [Select]
for f in `find /Root_Dir -name '*.flac'`; do metaflac --import-picture-from="${f%*.flac}.jpg" $f; done

Embedding album art in FLAC 1.1.4 images

Reply #3
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!

that's a one-liner in bash:
Code: [Select]
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

 

Embedding album art in FLAC 1.1.4 images

Reply #4
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.

Embedding album art in FLAC 1.1.4 images

Reply #5
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!

Embedding album art in FLAC 1.1.4 images

Reply #6
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: [Select]
#! /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: [Select]
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!

Embedding album art in FLAC 1.1.4 images

Reply #7
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.

Embedding album art in FLAC 1.1.4 images

Reply #8
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!

Embedding album art in FLAC 1.1.4 images

Reply #9
You can also make a flacpic.bat file (so you don't need bash), which also picks up "folder.jpg" if found:
Code: [Select]
@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.

Embedding album art in FLAC 1.1.4 images

Reply #10
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!    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!

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.

Embedding album art in FLAC 1.1.4 images

Reply #11
Can anyone explain to me how this BAT file works?  I've tried so many different things but nothing works.