Skip to main content

Topic: How do I remove padding after deleting metadata? (Read 10418 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • Anakunda
  • [*][*][*][*][*]
How do I remove padding after deleting metadata?
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.

  • tuffy
  • [*][*][*]
How do I remove padding after deleting metadata?
Reply #1
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: [Select]
metaflac --remove --block-type=PICTURE --dont-use-padding file.flac

  • Anakunda
  • [*][*][*][*][*]
How do I remove padding after deleting metadata?
Reply #2
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?

  • pdq
  • [*][*][*][*][*]
How do I remove padding after deleting metadata?
Reply #3
How serious of a problem could this be? Generally metadata is a tiny fraction of a lossless file.

  • Anakunda
  • [*][*][*][*][*]
How do I remove padding after deleting metadata?
Reply #4
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?

  • chi
  • [*]
How do I remove padding after deleting metadata?
Reply #5
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: [Select]
metaflac --dont-use-padding --remove --block-type=PADDING file.flac

  • Anakunda
  • [*][*][*][*][*]
How do I remove padding after deleting metadata?
Reply #6
This should do it:
Code: [Select]
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?

  • db1989
  • [*][*][*][*][*]
  • Global Moderator
How do I remove padding after deleting metadata?
Reply #7
“Rewrite file tags”?

  • Anakunda
  • [*][*][*][*][*]
How do I remove padding after deleting metadata?
Reply #8
“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.

  • marc2003
  • [*][*][*][*][*]
How do I remove padding after deleting metadata?
Reply #9
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.
  • Last Edit: 11 April, 2012, 05:45:03 PM by marc2003

  • Anakunda
  • [*][*][*][*][*]
How do I remove padding after deleting metadata?
Reply #10
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.

  • marc2003
  • [*][*][*][*][*]
How do I remove padding after deleting metadata?
Reply #11
apologies for not testing before posting. using "remove tags" doesn't even remove the artwork like it should.

  • derty2
  • [*][*][*][*][*]
How do I remove padding after deleting metadata?
Reply #12
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


  • Anakunda
  • [*][*][*][*][*]
How do I remove padding after deleting metadata?
Reply #13
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?

  • fbuser
  • [*][*][*][*][*]
  • Developer
How do I remove padding after deleting metadata?
Reply #14
What did I set wrong?

Using Destination:
Output folder: source file folder.
You cannot write to the same file which you are reading from

  • MrMonkey
  • [*][*][*]
How do I remove padding after deleting metadata?
Reply #15
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: [Select]
E:\metaflac.exe --remove --block-type=PADDING --dont-use-padding "%path%"
  • Last Edit: 22 January, 2014, 10:53:19 AM by MrMonkey

  • xapz
  • [*]
How do I remove padding after deleting metadata?
Reply #16
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: [Select]
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.