View Full Version : Add cover in flac with ffmpeg or metaflac ?
Music Fan
17th September 2016, 18:08
Hi,
is there a way to add a cover in flac files with ffmpeg ?
I searched but didn't find clear answer.
metaflac is also often mentioned on forums but I don't understand how to select input and output folders.
Ghitulescu
17th September 2016, 18:44
How about foobar 2k?
Music Fan
17th September 2016, 19:19
I don't have it, I'd like to use ffmpeg or metaflac.
Brazil2
17th September 2016, 20:03
metaflac is also often mentioned on forums but I don't understand how to select input and output folders.
https://xiph.org/flac/documentation_tools_metaflac.html
https://xiph.org/flac/documentation_tools_metaflac.html#metaflac_shorthand_import_picture_from
https://xiph.org/flac/documentation_tools_flac.html#flac_options_picture
Music Fan
17th September 2016, 22:53
I had already seen this but that's not very clear, there are not realistic examples, that's often the problem with command line tools.
richardpl
17th September 2016, 23:31
FFmpeg simply doesn't support that yet.
raffriff42
18th September 2016, 00:43
Realistic example (I know it works because I just tested it) -metaflac --import-picture-from="<image path>" "<FLAC path>"
Now you say, metaflac is also often mentioned on forums but I don't understand how to select input and output folders....implying you want a batch processing solution, correct? OK here is a batch script that will process all .FLAC files in a folder, adding .JPG images to them if the names are the same. @echo off
::** FLAC BATCH ADD COVER ART
:: target files must:
:: * have extension FLAC
:: * be in same folder with this batch file
:: art files must:
:: * have extension JPG (you can try changing this)
:: * be in same folder
:: * be named same as corresponding FLAC (except for the extension)
:: If it is not placed on your Windows PATH,
:: set full path to metaflac.exe below
set metaflac=metaflac
:: cover art image type
set IMGEXT=jpg
for %%f in (*.flac) do call :DOIT "%%f"
if ERRORLEVEL 1 pause
goto :EOF
:DOIT
if exist "%~n1.%IMGEXT%" %metaflac% --preserve-modtime ^
--import-picture-from="%~n1.%IMGEXT%" "%~nx1"
goto :EOF
Music Fan
18th September 2016, 07:48
Thanks !
Does it always replace the original files by the tagged ones ? If yes, I should first copy the whole folder in another place if I wanna keep an untouched version.
And how to modifiy the batch if I wannna use the same jpg for all flac files in a folder ?
edit : actually I guess I can replace
--import-picture-from="%~n1.%IMGEXT%" "%~nx1"
by
--import-picture-from="cover.jpg" "%~nx1"
if there is a picture named cover.jpg in that folder.
edit 2 : after a few tests, I finally found a short working script to use a single jpeg for all flac files ;
for %%f in (*.flac) do "C:\Program Files (x86)\FLAC Frontend\tools\metaflac.exe" --preserve-modtime --import-picture-from="cover.jpg" "%%f"
pause
raffriff42
18th September 2016, 15:21
>Does it always replace the original files...
[EDIT misunderstanding "files" as "image files",] it seems to add a second front cover without removing the old, which seems unhelpful. You can run the script below to remove all pictures, then add your own cover art afterwards.
>I should first copy the whole folder in another place if I wanna keep an untouched version.
Backing up is never a bad thing, but here is a script to remove all embedded pictures (including back covers etc if present)
FLAC-remove-art.bat@echo off
::** FLAC BATCH REMOVE COVER ART
:: target files must:
:: * have extension FLAC
:: * be in same folder with this batch file
:: If it is not placed on your Windows PATH,
:: set full path to metaflac.exe below
set metaflac=metaflac
for %%f in (*.flac) do call :DOIT "%%f"
if ERRORLEVEL 1 pause
goto :EOF
:DOIT
%metaflac% --preserve-modtime ^
--remove --block-type=PICTURE "%~nx1"
@echo.
goto :EOF
>I finally found a short working script to use a single jpeg for all flac files
You're getting the idea! :) But not seeing your post, I wrote a batch script which accepts an image argument.
FLAC-add-art.bat@echo off
::** FLAC BATCH ADD COVER ART
:: target files must:
:: * have extension FLAC
:: * be in same folder with this batch file
:: art files given as argument
:: (via command line or drag-and-drop)
:: If it is not placed on your Windows PATH,
:: set full path to metaflac.exe below
set metaflac=metaflac
if (%1)==() goto USAGE
for %%f in (*.flac) do call :DOIT "%%f" "%~pnx1"
if ERRORLEVEL 1 pause
goto :EOF
:DOIT
%metaflac% --preserve-modtime ^
--import-picture-from="%~pnx2" "%~nx1"
@echo.
goto :EOF
:USAGE
@echo missing required argument
@echo usage %~nx0 "path\to\cover-art-file"
@echo.
goto :EOF
Music Fan
18th September 2016, 16:01
Thanks.
It seems to add a second front cover without removing the old, which seems unhelpful. You can run the script below to remove all pictures, then add your own cover art afterwards.
My files don't have cover yet, that's why I wanna tag them.
But metaflac doesn't seem able to create new files in another folder, thus input = output.
raffriff42
18th September 2016, 17:44
OK I misunderstood the question. Right, input = output.
BTW it works the same with atomicparsley (http://atomicparsley.sourceforge.net/) and MOV/MP4/(M4A?):atomicparsley "to_be_modded.mp4" --artwork "cover.jpg"
Music Fan
20th September 2016, 09:52
Thanks, I tried this for my m4a (aac) files but for some reasons, my Android phone does not detect the cover tag in m4a files (whatever it was tagged with mp4tag, mp4box or atomicparsley). But it does with flac & mp3.:confused:
I mean when I use Google Play Music, I didn't try any other player.
Music Fan
25th September 2016, 19:42
Thanks, I tried this for my m4a (aac) files but for some reasons, my Android phone does not detect the cover tag in m4a files (whatever it was tagged with mp4tag, mp4box or atomicparsley). But it does with flac & mp3.:confused:
I mean when I use Google Play Music, I didn't try any other player.
I tried again to tag m4a with atomicparsley and now the cover is displayed by my smartphone !?
The only problem being that atomicparsley adds -temp- followed by numbers at the end of filenames.:o
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.