IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
How do I remove padding after deleting metadata?, Was: Compressing metadata?
Anakunda
post Apr 11 2012, 14:56
Post #1





Group: Members
Posts: 465
Joined: 24-November 08
Member No.: 63072



HI!! Is there something able to rebuild a FLAC file from scratch or simply compress ezisting metadata? I figured out that when I insert an exhaustive tag such as large cover picture then remove it, the FLAC file won't shrink! Replacing an attachment by a bigger one obviously biggers the file. Of course I need the tool to preserve all existing metadata.
Go to the top of the page
+Quote Post
tuffy
post Apr 11 2012, 15:11
Post #2





Group: Members
Posts: 111
Joined: 20-August 07
Member No.: 46367



With metaflac, you're looking for the --dont-use-padding option which tells it not to replace the removed picture with padding, such as:
CODE
metaflac --remove --block-type=PICTURE --dont-use-padding file.flac
Go to the top of the page
+Quote Post
Anakunda
post Apr 11 2012, 15:18
Post #3





Group: Members
Posts: 465
Joined: 24-November 08
Member No.: 63072



Thanks for quick response, unfortunatelly I don't use metaflac to handle a flac metadata, so I already have a FLAC with superfluous padding block(s).
What does --merge-padding --sort-padding do and is there a option that flushes spare padding blocks?
Go to the top of the page
+Quote Post
pdq
post Apr 11 2012, 15:53
Post #4





Group: Members
Posts: 3412
Joined: 1-September 05
From: SE Pennsylvania
Member No.: 24233



How serious of a problem could this be? Generally metadata is a tiny fraction of a lossless file.
Go to the top of the page
+Quote Post
Anakunda
post Apr 11 2012, 16:13
Post #5





Group: Members
Posts: 465
Joined: 24-November 08
Member No.: 63072



In case of pure text metadata this issue is negligible but imagine 10 album tracks containing each 1MB cover image, now wanting to cleanup the superfluous non audio data there's total 10MB of discardable data blocks that can't be freed?
Go to the top of the page
+Quote Post
chi
post Apr 11 2012, 21:07
Post #6





Group: Members
Posts: 45
Joined: 27-November 11
Member No.: 95439



QUOTE (Anakunda @ Apr 11 2012, 15:18) *
unfortunatelly I don't use metaflac to handle a flac metadata, so I already have a FLAC with superfluous padding block(s).
What does --merge-padding --sort-padding do and is there a option that flushes spare padding blocks?


This should do it:
CODE
metaflac --dont-use-padding --remove --block-type=PADDING file.flac
Go to the top of the page
+Quote Post
Anakunda
post Apr 11 2012, 21:28
Post #7





Group: Members
Posts: 465
Joined: 24-November 08
Member No.: 63072



QUOTE (chi @ Apr 11 2012, 22:07) *
This should do it:
CODE
metaflac --dont-use-padding --remove --block-type=PADDING file.flac

Thanks so much. I tried it, it does exactly what I asked for. Any chance to perform on selection via foobar rightclick menu?
Go to the top of the page
+Quote Post
db1989
post Apr 11 2012, 21:36
Post #8





Group: Super Moderator
Posts: 5275
Joined: 23-June 06
Member No.: 32180



“Rewrite file tags”?
Go to the top of the page
+Quote Post
Anakunda
post Apr 11 2012, 21:45
Post #9





Group: Members
Posts: 465
Joined: 24-November 08
Member No.: 63072



QUOTE (db1989 @ Apr 11 2012, 22:36) *
“Rewrite file tags”?


Tried that and it won't opt out free blocks.
I`m trying with "Run services" and command string

cmd /c for %i in ("%directoryname%\*.flac") do D:\media\lossless\metaflac.exe --dont-use-padding --remove --block-type=PADDING "%~fi"

It won't work for some reason however.
Go to the top of the page
+Quote Post
marc2003
post Apr 11 2012, 22:44
Post #10





Group: Members
Posts: 4472
Joined: 27-January 05
From: England
Member No.: 19379



as you're using foobar2000, highlight all fields in the properties dialog for the selected files. right click>copy. now click on the tools button>remove tags. finally right click and paste fields.

as always, test on a subset of copied files first.

This post has been edited by marc2003: Apr 11 2012, 22:45
Go to the top of the page
+Quote Post
Anakunda
post Apr 11 2012, 23:38
Post #11





Group: Members
Posts: 465
Joined: 24-November 08
Member No.: 63072



QUOTE (marc2003 @ Apr 11 2012, 23:44) *
as you're using foobar2000, highlight all fields in the properties dialog for the selected files. right click>copy. now click on the tools button>remove tags. finally right click and paste fields.

as always, test on a subset of copied files first.

This didnot rebuild FLACs either. Seems metaflac only does the optimization.
Anyway I'd like the same function as Utilites->Optimize MP4 Layout for FLACs as those apply a fragmentation effect too.
Go to the top of the page
+Quote Post
marc2003
post Apr 12 2012, 00:51
Post #12





Group: Members
Posts: 4472
Joined: 27-January 05
From: England
Member No.: 19379



apologies for not testing before posting. using "remove tags" doesn't even remove the artwork like it should.
Go to the top of the page
+Quote Post
derty2
post Apr 12 2012, 01:16
Post #13





Group: Members
Posts: 581
Joined: 5-June 11
Member No.: 91257



Create a custom foobar2000 converter action...

For example:

Encoder:                   metaflac.exe
Extension:                 flac
Parameters:               -s --dont-use-padding --remove --block-type=PADDING -o %d
Converter name:         METAFLAC
Bitrate:                     blank
Settings:                   Strip padding from FLAC files

Go to the top of the page
+Quote Post
Anakunda
post Apr 12 2012, 08:24
Post #14





Group: Members
Posts: 465
Joined: 24-November 08
Member No.: 63072



QUOTE (derty2 @ Apr 12 2012, 02:16) *
Create a custom foobar2000 converter action...


I'm trying this profile and get error console with 18 out of 18 tracks converted with major problems. For each file I get error
Source: "E:\test\01 - Track01.flac"
Unable to open file for writing (File is already in use) : "E:\test\01 - Track01.flac"
Conversion failed: File is already in use

Using Destination:
Output folder: source file folder.
Output type: tracks into individual files.
File name pattern: %filename%
Overwrite existing files.

Processing: None.
Other: When finished: do nothing.

What did I set wrong?
Go to the top of the page
+Quote Post
fbuser
post Apr 12 2012, 09:18
Post #15





Group: Developer
Posts: 683
Joined: 26-September 07
Member No.: 47369



QUOTE (Anakunda @ Apr 12 2012, 08:24) *
What did I set wrong?

QUOTE (Anakunda @ Apr 12 2012, 08:24) *
Using Destination:
Output folder: source file folder.
You cannot write to the same file which you are reading from
Go to the top of the page
+Quote Post
MrMonkey
post Jan 22 2014, 16:51
Post #16





Group: Members
Posts: 80
Joined: 22-August 10
Member No.: 83276



Here's a way to strip excessive padding in foobar2000 without using the converter. Instead, this approach uses foo_run. Sometimes purchased FLAC files come with huge embedded artwork repeated across each file. I'll extract the artwork to the same directory as the FLAC files and then delete the embedded artwork. However, if the extra padding is not removed, the FLAC files will remain at the inflated size. Stripping the extra padding reduces the file size without touching the audio or other tags.

Here is the relevant info from that link in case that page disappears someday:
QUOTE
You can use the foobar component foo_run to run metaflac.

Install the component, then go to the foobar Preferences -> Tools -> Run services and add a new service. Label it something like "Strip Images and Padding", use the [...] button to locate your metaflac.exe, add the parameters --dont-use-padding --remove --block-type=PICTURE,PADDING and put the variable %path% behind it. Don't forget to put it into double quotes, just in case a path contains spaces. Tick the "minimize" checkbox and crank the "Simultaneous runs" slider up to the maximum (lowering this will limit the amount of files you can process at once).


Link to foo_run.

For what it's worth, I strip the padding only (i.e. I don't add the PICTURE block type above) because I manually remove the artwork after extracting it. So my service is:
CODE
E:\metaflac.exe --remove --block-type=PADDING --dont-use-padding "%path%"


This post has been edited by MrMonkey: Jan 22 2014, 16:53
Go to the top of the page
+Quote Post
xapz
post Aug 26 2014, 23:11
Post #17





Group: Members
Posts: 18
Joined: 3-July 09
Member No.: 71174



There's one downside to using metaflac with the above method. The used command line options remove ALL padding from the FLAC files. This isn't necessarily an issue, but padding serves a purpose. If metadata gets added or changed on a file without any padding, even if it's just fixing a small typo in a title, the whole file needs to be re-written on the HDD. Depending on the amount of files you're editing, the file sizes (think about high resolution multi-channel stuff) and speed of your drive, this may take longer than you'd expect.

So it's definitely desirable to have a small amount of padding in all files, because then such small metadata changes are practically instant, because that new information just gets written over a part of the padding (that's probably a cringe-worthy explanation from a technical point of view, but that's how I imagine it to work). That's why the default setting in the FLAC encoder adds a small amount of padding to all files (it's 4 or 8 KiB, if I'm not mistaken). The problem with metaflac is, that you need to run it twice to achieve this. First to remove the picture and all padding, then a second time to add a healthy amount of padding again. It's not possible to do this in one run.

I haven't done much with foo_run yet, but I believe it should be possible to chain two commands in one command? So taking the example from MrMonkey's post, adding 8 KB of padding after removing it completely, would look something like this:

CODE
E:\metaflac.exe --remove --block-type=PADDING --dont-use-padding "%path%"
E:\metaflac.exe --add-padding=8192 "%path%"


I was thinking about creating a new thread, but then I found this one. I'm not sure, if this is the place to ask for feature requests for foobar, though. It would be great, if foobar allowed adjustment of advances settings regarding padding in FLAC files. I imagine it would be possible to add a setting to actually remove images from the FLAC files without replacing it with padding, and leaving a small default amount of padding in the files. Metaflac does its job well, but a native foobar solution would be so much more convenient.

My assumption is, that the majority of people aren't even aware of this behaviour in foobar or also MP3Tag. They see that the image is "gone" after removing it via the tag editors, but don't realize that their FLAC files didn't get any smaller.
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: 1st October 2014 - 10:03