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: [S] Command line tool to export cover art from LC AAC files metadata (Read 845 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[S] Command line tool to export cover art from LC AAC files metadata

Hi guys,

Short story: I want to mass export cover art from LC AAC files. I need to do it automatically in the future via cmd batch scripting, so it needs to be a command line capable tool. Do you know one?

Long story: For my target devices, I create lossy files, which hold embedded art. Good enough for most devices, but some need a jpg file beside the audio file.
My folder structure is by classical music artists and works. The source album has no meaning, contents from one album may be split into different folders. Here is a problem. Foobar2000s converter copies files (in "copy other files to the destination folder") only into the first created folder. It does not take into account there can be multiple destination folders. In effect I cannot use this.
So my plan is (I made a suggestion to fb2k dev 2x over many years about this, but no reaction) - to just create the lossy files and then extract their album art in a post process.

Re: [S] Command line tool to export cover art from LC AAC files metadata

Reply #1
Can answer the question myself. Tested this one successfully:

https://code.google.com/archive/p/mp4v2/

Here's the Windows binaries. The 32 bit version works on my Windows 10.
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/mp4v2/mp4v2-r479-windows-binaries.zip

Here's my quick script. A full directory path is sent to it and it does its job recursively. Output is one folder.jpg per directory.
Some of my files have embedded webp, which I convert to jpg with nconvert. Increasing loss on lossy images - I don't care. Nconvert command line is a bit overkill, coming from a background of dealing with multilayer png.

Code: [Select]
@echo off

SET MP4V2="m:\Musik\Library\Player\tools\mp4v2\mp4art.exe"
SET NCONVERT="C:\Program Files\XnConvert\nconvert.exe"
SET NCONVERTCOMMAND=-overwrite -transpcolor 255 255 255 -merge_alpha -resize longest 1000 -rflag decr -ratio -rtype lanczos2 -rflag decr -out jpeg -q 75 -subsampling 2 -opthuff -o

FOR /R %1 %%G IN (*.m4a) DO CALL :EXTRACT_ART "%%G"
GOTO :EOF

:EXTRACT_ART
IF NOT EXIST "%~dp1folder.jpg" %MP4V2% --extract --art-index 0 -k -o %1
IF EXIST "%~dpn1.art[0].jpg" REN "%~dpn1.art[0].jpg" folder.jpg
IF EXIST "%~dpn1.art[0].webp" %NCONVERT% %NCONVERTCOMMAND% folder.jpg "%~dpn1.art[0].webp"
EXIT /B