How to decrease the tagsize after deleting coverart


#1

I just received some FLAC files that had coverart embedded. The .jpg files that were embedded were however way too big: about 4-6 MB per FLAC!
MP3Tag took ages to read these huge tags in the total of 230 files, probably because of these huge tagsizes. So I deleted all coverart via the "extended tags".

However, the tagsize is still indicated to be between 4 and 6 MB per FLAC, even after the deletion of all coverart ...

Is there any way decrease the tagsize ? I already deleted all tags and pressed "undo", without any result.


How to remove cover art AND shrink file size?
How to remove excessive padding from FLAC files?
Didn't update file size after deleting a jpg cover file in a FLAC audio File
Removing cover art to save space ?
Cover and file size
#2

After some searching I found that apparently the space in the FLAC used by an embedded image is indeed "padded" when removing the image.

So the question seems to be how to remove this huge padding in the picture metadata block.
I saw that perhaps this could be done with Metaflac, if I understand correctly using the switches: "--remove --block-type=PADDING --dont-use-padding"
Can this be made to work only on the picture metadata?

Alternatively, I saw that there was also a switch "--remove-all --dont-use-padding"
But would this also delete the normal tags such as "title" and I'm not quite sure whether this would also remove existing padding ...

Anyway, this is becoming a bit too technical for me, does someone have any experience with this?


#3

Sorry to keep answering myself, but I found a solution via metaflac used in a batchfile, that seems to work.

@echo off
title Reduce padding in FLAC - all files in directory
for %%i in (*.flac) do (
echo Removing padding from "%%~ni.flac" ...
"\metaflac.exe" --remove --block-type=PADDING --dont-use-padding "%%~ni.flac"
if ERRORLEVEL 1 goto error
echo Adding 4096 bytes of padding ...
"\metaflac.exe" --add-padding=4096 "%%~ni.flac"
if ERRORLEVEL 1 goto error
echo -- Done
echo.
)
echo.
echo -- Padding reduced
goto end
:error
echo.
echo ---- ERROR REDUCING PADDING ---- batch process stopped
:end
echo.
pause
exit

Save this as f.i. "ReduceFLACPadding.bat" and place in the right-context-menu folder of explorer. This will reduce any oversized padding in all FLACs in the directory to a standard 4096 bytes, leaving the existing tags intact.


Flac and tags
#4

I also had audio files with huge cover art, and hopped I could find help here, but not much.
Turned out that J. River Media Center do the job easily, and version 12 is free.
However do not scan to update the library, as Media Center will embed the cover art by default.


#5

I'm so free and hijack this thread about the padding size in FLAC files, and want to give thanks to Lupercus for his batch file using the commandline tool "metaflac.exe", which I have used as a template.
I wrote an extended version of the batch file, see attachment.

@ECHO OFF

REM ================================================================================
REM Purpose: Change the padding size within all FLAC files in the given folder .
REM The given folder path name can be dropped onto this batch file ...
REM ... or can be set as the first parameter on the command line.
REM This CMD script is an extended version of the CMD script from Mp3tag user "Lupercus, Sep 5 2009, 13:52" .
REM Detlev Dalitz.20140106.
REM ================================================================================
REM Define the fully qualified path to the file "metaflac.exe".

SET METAFLAC="P:\Programs\FLAC\metaflac.exe"
REM Define the padding default size in Bytes.
REM The pad size is allowed to be an integer value in the range from 0 to 16777215.

SET PADSIZE_DEFAULT=2000
REM ================================================================================
ECHO.[%~n]
ECHO.
ECHO.Set padding for all FLAC files in the current folder ...
CD /D "%~f1"
ECHO."%CD%"
IF NOT EXIST ".FLAC" (
ECHO.
ECHO.FLAC files not found.
GOTO END
)
:GET_PADSIZE

ECHO.
SET PADSIZE_INPUT=%PADSIZE_DEFAULT%
SET /P PADSIZE_INPUT=Give padding size in Bytes (default %PADSIZE_DEFAULT%):
SET /A PADSIZE_EVAL=1%PADSIZE_INPUT%
IF %PADSIZE_EVAL% NEQ %PADSIZE_INPUT% (
ECHO.Enter an integer number in the range ...
ECHO.decimal ...: from 0 to 16777215
ECHO.hexadecimal: from 0 to 0xffffff
ECHO.octal .....: from 00 to 077777777
GOTO GET_PADSIZE
)

ECHO.Set padding to %PADSIZE_EVAL% Bytes.
ECHO.
ECHO.Press [Enter] to continue or [Ctrl+C] to exit.
PAUSE >NUL
ECHO
.
SET COUNT=0
FOR %%f IN ("*.FLAC") DO (
REM ATTRIB -R "%%~nxf"
REM ECHO."%%~nxf"
REM ECHO.%%~ftzaf

SET /A COUNT=!COUNT!+1
ECHO.
ECHO.!COUNT!:
ECHO.Remove padding from ...
DIR /N/4 "%%f"|FIND "%%f"
%METAFLAC% --dont-use-padding --remove --block-type=PADDING "%%~nxf"
IF ERRORLEVEL 1 GOTO ERROR
ECHO.Add padding %PADSIZE_EVAL% Bytes ...
%METAFLAC% --add-padding=%PADSIZE_EVAL% "%%~nxf"
IF ERRORLEVEL 1 GOTO ERROR
DIR /N/4 "%%f"|FIND "%%f"
ECHO.
REM PAUSE

)

ECHO.
ECHO.Ready.
GOTO END
:ERROR

ECHO.
ECHO.Error on reducing padding ... batch process stopped.

:END

ECHO.
PAUSE
EXIT

MetaFlac.SetPadding.cmd.txt (2.25 KB)
For usage remove the extension ".txt" from the filename.

DD.20140106.2356.CET

Note:
This cmd script makes use of "delayed variable expansion".
To use delayed variable expansion it must be enabled.

This can be done using CMD /V:ON /C to start the batch file, ...
or better insert the code line ...
SETLOCAL ENABLEDELAYEDEXPANSION
... inside the batch file.

To make it permanently ...
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"DelayedExpansion"=dword:00000001

DD.20150515.1120.CEST

MetaFlac.SetPadding.cmd.txt (2.25 KB)


Metaflac.exe
#6

Hi Detlev,

I really like your script.

But I get two "errors". The Script itself works fine.

Set padding for all FLAC files in the current folder ...
Die Syntax f├╝r den Dateinamen, Verzeichnisnamen oder die Datentr├Ągerbezeichnung
ist falsch.
"F:\__Comedy\Badesalz\[1991-00-00] Nicht Ohne Meinen Pappa"

And before every file:

Fehlender Operator

The only thing I did was to change the path to the metaflac.exe.

Also I would appreciate it if instead of stopping the script on an error to put the errornous file into a txt-file. Full qualified path + txt-file can be written to any location and not just the source directory.


#7

I have just no time to dig into the problem.

Maybe the path to the metaflac.exe file contains one ore more space characters? Do avoid this.
Or ... try to enclose the DOS variable into Double Apostrophes.
%METAFLAC% ==> "%METAFLAC%"
I don't know if this can help.

Feel free to modify the batch script to your needs.

DD.20141202.1348.CET


#8

i get same errors but works fine
however is it possible this batch works with subfolders ?
i try unsuccessfuly to change it
thanks a lot Detlev


#9

The "MetaFlac.SetPadding.cmd" batch file accepts only one parameter, ...
which is given as a commandline parameter, ...
or given by drag and drop onto the commandfile's icon.
This parameter is the folderpathname of the folder, which contains the *.flac files to be changed.
Recursive walk through a foldertree is not implemented.

DD.20150514.1935.CEST


#10

A little help please, I got this error: "P:\Programs\FLAC\metaflac.exe" not recognized as an internal or external command


#11

You have to edit the code and set the call of the program to the actual location in your filesystem where metaflac.exe can be found.
modify this line:
SET METAFLAC="P:\Programs\FLAC\metaflac.exe"


#12

what a noob... Thanks a lot. :smiley: :music:


#13

Something else to note: You can use metaflac.exe to remove the images themselves. No need to do it manually in Mp3tag and then run a script to remove the excess padding.

--remove --block-type=PICTURE

And if you wish to preserve file modification times, use:

--preserve-modtime