Is there a way to remove silence at the end of files

I've collected over 3,000 mp3 files for 10 years, and from time to time I made updates to the album artwork by using iTunes on Mac which is my default player. For some of the files, I've made back and forth updates a few times by removing the artwork image used previously and then inserted a new one. Only just the last a few weeks, I've noticed that lots of my files have some errors that their playing time is much longer than they were supposed to be (could be up to 10+ seconds) which bothers me a lot. It took me a while to understand it was caused by the "padding" to the ID3 tags. I've been searching for a solution on Google hoping to adjust those files to their original playing time and organic file size, and it leads me to mp3tag yesterday. It seems to me that mp3tag can avoid new padding, which is great for my future editing. But is there a feature that can help remove existing padding? Many thanks in advance.

MP3tag manages the padding according to its needs - and removes padding for mp3 files when re-writing the files.

Your observation that the playing time of a file changes after updating tags (only they lead to padding) should be an alarm signal in respect to the integrity of the files as any decent player does not add the tag data to the payload data.
See here for tools to check files:

Thank you so much for your kind help, but it doesn't seem like a direct solution to my problem, which is probably my fault, as I don't think I've made clear elaboration on my inquiry.

What I've been doing in the last 10 years is just use "iTunes" to edit tags, in particular updating album arts, and here is how I did it:

Step 1, Import mp3 files into iTunes

Step 2, Insert album image - Save file
(The file size increased, the file's playing time remains the same)

Step 3, Remove album image - Save file
(The file size remains the same, the file's playing time increased)

And if I repeat step 2 and step 3 for a few times, the file's size and playing time will continue to grow.

So my assumption here is that whenever I remove an image from the file, it creates the padding, but the file somehow has to remain the same size, and that automatically leads to the creation of excessive playing time in the end of the track.

And in order to remove that bit of excessive playing time, I think I need to find a way (ideally via using mp3tag) to remove the padding as well as the file size, does that make sense?

... and exactly this should be an alarm signal, as apparently your process either rewrites the file in a way that ignores the real tag size or iTunes has a strange way to calculate the playing time.
The tag size should never influence the playing time.
Please check with the linked tools the integrity of the files and also check if other players report the same playing time.

Thanks again. I would love to follow your recommended approach, and since my purpose is not only to identify whether the integrity of the files is intact, but to find a way to fix the errors, so which one out of the three tools should I go with? Maybe MP3val or Foobar 2000?

I would start with MP3diags

And yes I've tried playing the files edited by iTunes/Apple Music on other music players, such as the default music player on Windows PC, the playing time is also increased. So as you said, maybe the problem is actually with iTunes/Apple Music?

I would first of all wait for the results of the integrity check.
Then I would load a file in MP3tag, cut the tag and paste it immediately afterwards and then see what that does to the file size and the playing time.
If you cut a tag, then this should lead to an tag empty column (the one, that really says ID3V2.3 etc).
And once we found out whether the file is OK, then it would be worthwhile to see who is to blame for the errors.
In general: iTunes is not the best tagging program (and neither is WMP).

If all this is too complicated, then please supply a file so that others in the forum can check it.

Thank you so much. If it's not too much trouble, I may just take the short cut and share download links to my files in this thread and leave it to the experts. I'm thinking maybe I should upload two files, one original file downloaded from wherever I purchased the track, and another file from the same origin but has been edited by iTunes with inflated size and playing time. Would that be enough?

Yes, go ahead. I hope something can be found to help you.

Cool, I'll post the files via wetransfer links later today. Can't appreciate enough for your help. Cheers.

I've uploaded two files to the link as follows, respectively the original file and the one that's been edited by using iTunes. Hope that would be enough for the diagnose. Thanks again.

The editted file shows a lot of errors:

or here:

Which means that the problems arise from the corrupted file structure.
MP3diags can handle most of the errors.
Still, the original file has 11 seconds of silence at the end, the editted one has 21 seconds - this is more or less the amount of playtime difference.
This added silence at the end of the audio part has nothing to do with padding and cannot be handled by MP3tag.
So, in short: your editing process messes up the files.

The next picture shows the added silence at the end:

So, I would run MP3diags on the whole collection, perhaps not in 1 go but in effect.

I have never experienced this before, and have been using iTunes as my main library for browsing since it came out. I too used it for doing all of my editing, before finding mp3tag as a significantly better resource around 10 years ago. Occasionally I will still add a cover in iTunes if it is something I am doing quickly on the fly.

To test for what you are seeing, I tried with both m4a and mp3 file types just now, adding 3 different cover images in iTunes, one at a time, and saving. No time was added to my files, but of course the file size increased. I removed all of the test images, and the file sizes shrank and the time remained the same as expected.

I didn't try this with your sample files, but given the errors indicated by the testing done by @ohrenkino above, I would suggest those stream issues would have contributed to the problem whenever iTunes was writing back to the header. If you are able to successfully repair the original file, I am positive that edits to the tag data will no longer affect the actual track length.

Do you have access to the original source of the files, or if you ripped from your own CD collection can you try a modern rip to start?

I would like to add that the file labelled as "original" does not show any problem. So it must be the editing.

MP3diags found 15 ID3V1 tags before it aborted the analysis. I wonder which program wrote these strange frames.

I went ahead and downloaded your samples. There were definitely errors with the file that you had edited. The original didn't have any stream errors, just missing some tag header info.

I added the original file to my iTunes library, then edited it to add 2 covers. After saving the changes, the file size increased but the time remained at 6:18. I verified this checking it with mp3tag, both covers were there and the time indication was unchanged. Testing again with mp3diags showed just two more issues, both related to the original ones, and certainly nothing that impacts the audio section or track length.

Seems there is something else involved here. Perhaps you have your music folder being "monitored" by a program like WMP or similar that is also affecting this?

EDIT: (sample files have been deleted from my system)

Thank you so much for running the test. It's shocking to know that the editted file has got so many errors, as I've done nothing to it, apart from add / remove the album images a number of times using iTunes.

So for that "editted file", is there anything wrong with the audio part? I think it would be worthwhile for me to invest a few weekends of time to fix all those files if only their audio parts are still intact.

MP3diags is able to remove all the invalid streams from the files - or at least from the sample file.
What remains are the 10 extra seconds of silence. I don't know how they got added but as you wrote: you noticed an increase in playing time. And that increase are those 10 seonds in the sample file. As that is valid audio data (even though probably not wanted data), it will not be removed along with the invalid data.
So, if you still have access to the original files, I would use those.
MP3tag can copy a whole tag with all the fields including the picture from one file to another - or even a set of files as long as source and target files are in the same order and the same number of files.

So kind of you doing the test on iTunes, and many thanks to that. I see you've added the covers, but you may as well try to remove those covers (better to use >100KB image file) by using iTunes, and just repeat the add-save-remove-save process on iTunes for maybe three or four times, I think the change in playing time and file size would be more visible by then.