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: discussion of fix mp3 header plugin (Read 36816 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

discussion of fix mp3 header plugin

what does it exactly do?
should i use it for all my lame encoded files with the setting 576 (encoder delay), 0 (padding)
is it safe to use?
is it recomended to use?
will other players have problems with the "fixed" mp3 headers ?
what is padding? does this have something to do tags ? i only use ape2 tags if this helps

discussion of fix mp3 header plugin

Reply #1
Quote
what does it exactly do?
It's yet another "vbrfix"-style tool, but with option to edit gapless playback values (probably also faster / more reliable than other "vbrfix" programs from what I've heard).
Quote
should i use it for all my lame encoded files with the setting 576 (encoder delay), 0 (padding)
Files encoded with recent LAME should have correct headers with gapless playback info already most of the time (but they apparently don't have if encoded with certain frontends), easy way to check: reported sample count (in file info box) should be a multiply of 588 (cd sector size); reload info from file before checking so you can be sure that reported length you get hasn't been read by old version of mp3 input that didn't support gapless playback.
You can also use this feature on files that have been encoded with different encoders than LAME (they may need different encoder delay though).
Quote
is it safe to use?
I think it's safe (I haven't seen any files being damaged by it so far; it even preserves all sorts of tags); hasn't been tested too much though.
Use it only where you need to - eg. for fixing reported length of some weird files (also on CBR files), or for making non-gapless MP3s play gaplessly.
Quote
will other players have problems with the "fixed" mp3 headers ?
No, these headers follow LAME header spec from Gabriel's page (also compatible with Xing headers for VBR files), all files encoded with semi-recent LAME have similar headers already; also, those headers are valid MP3 frames (unlike all other tags). If you use a player unaware of them (if one still exists), header will simply produce a silent frame at the beginning of file.
As far as I'm aware of, no other player uses gapless playback info from those headers at the monent.
Quote
what is padding? does this have something to do tags ? i only use ape2 tags if this helps
Padding represents amount of null samples (silence) added at the end of file to complete last MP3 frame. Header fix doesn't let you edit padding directly; instead you can enter desired length (in samples) of entire file (which is more useful this way).

There are two ways to get correct length of MP3 file:
a) bruteforce method - run fix on entire album (sorry, it needs per-file settings so it can't be used on multiselection) with proper delay and no padding, then run it again on each file, round reported length in samples down to nearest multiply of 588, listen to the file; if still produces gap - keep subtracting 588 from sample count until you find value that sounds "right".
b) find correct cuesheet for that album (hint: try this site) and extract length values from it - either by substituting referenced file with something and loading the cue in fb2k, or by opening the cue in notepad and calculating lengths from index positions (cue time format: hh:mm:ss:ff, where ff is in 1/75-second frames; one frame has 588 samples).
Note that either method doesn't let you find correct length of last track in album, but that's rather unimportant.
I've fixed 2 albums using the bruteforce method, then found cues and values I "guessed" turned out to be 100% accurate.

[edit] i'll start killing people next time i see "B)" emoticon popping out of nowhere in my text
Microsoft Windows: We can't script here, this is bat country.

discussion of fix mp3 header plugin

Reply #2
thanks alot for your anwser. makes things alot clearer and easier to understand for me and maybe some others too!

discussion of fix mp3 header plugin

Reply #3
I was planning to write such tutorial anyway (to put it in the FAQ perhaps). This headerfix is just too useful.
Microsoft Windows: We can't script here, this is bat country.

discussion of fix mp3 header plugin

Reply #4
Quote
Files encoded with recent LAME should have correct headers with gapless playback info already most of the time (but they apparently don't have if encoded with certain frontends), easy way to check: reported sample count (in file info box) should be a multiply of 588 (cd sector size); reload info from file before checking so you can be sure that reported length you get hasn't been read by old version of mp3 input that didn't support gapless playback.

I think it would be useful if we could see in the file info box a confirmation under the number of samples that it is a multiply of 588 or not, so we won't have to do any calculations.

discussion of fix mp3 header plugin

Reply #5
Quote
Quote
Files encoded with recent LAME should have correct headers with gapless playback info already most of the time (but they apparently don't have if encoded with certain frontends), easy way to check: reported sample count (in file info box) should be a multiply of 588 (cd sector size); reload info from file before checking so you can be sure that reported length you get hasn't been read by old version of mp3 input that didn't support gapless playback.

I think it would be useful if we could see in the file info box a confirmation under the number of samples that it is a multiply of 588 or not, so we won't have to do any calculations.

Copy sample count, winkey+R, calc.exe, paste sample count, divide by 588, see if result is an integer.
Simple enough ?
Microsoft Windows: We can't script here, this is bat country.

discussion of fix mp3 header plugin

Reply #6
Can't get any simpler than that  ok man, no big deal  I only asked for it just for convenience.

discussion of fix mp3 header plugin

Reply #7
Quote
a) bruteforce method - run fix on entire album (sorry, it needs per-file settings so it can't be used on multiselection) with proper delay and no padding, then run it again on each file, round reported length in samples down to nearest multiply of 588

Isn't it up to nearest multiply, so e.g 13234223 -> 13234704?
I think rounding down should be used when no encoder delay yet specified.

In other words I can do either:

- first put encoder delay with padding set to 0, then round up to nearest sector
- or put both encoder delay and amount of samples rounded down (or get lenghts from cue, but on couple of albums I tried those values mach) (?)

...

Hmm, although cue might provide wrong values, if file has stream errors, it seems.

discussion of fix mp3 header plugin

Reply #8
It is rounding down (rounding up would mean adding extra null samples, while we want to do the opposite).
Anyway, rounding down to nearest multiply to 588 isn't usually enough, you have to go down by one or two 588-sample sectors to get correct value (there's another value - decoder delay: 529 samples used internally, but it's not "user-visible" anywhere, except it affects reported length).
Microsoft Windows: We can't script here, this is bat country.

 

discussion of fix mp3 header plugin

Reply #9
where can i dl this plugin ? any link ?

discussion of fix mp3 header plugin

Reply #10
Quote
where can i dl this plugin ? any link ?

included in the latest betas of 0.7
just click with the right mousebutton on any mp3 file.
edit: if you still don't see it make sure that you have this button enabled under "context menü items"

discussion of fix mp3 header plugin

Reply #11
Latest beta(s), ok thanks

discussion of fix mp3 header plugin

Reply #12
Quote
Latest beta(s), ok thanks

hm whats the plural of beta?
i meant that it's not only included in 27 but maybe in 26 and 25 too, anthough i'm not sure 

discussion of fix mp3 header plugin

Reply #13
Quote
Quote

I think it would be useful if we could see in the file info box a confirmation under the number of samples that it is a multiply of 588 or not, so we won't have to do any calculations.

Copy sample count, winkey+R, calc.exe, paste sample count, divide by 588, see if result is an integer.
Simple enough ?

I understand that this is simple enough, but imagine the zillion users foobar doing maths with the thousand mp3 they have.

I guess that half of that zillion users would prefer that division to be automated inside foobar.

discussion of fix mp3 header plugin

Reply #14
While we're on the topic of gapless play back and the "fix mp3 header" function in foobar, I thought I would share my experience in the hope it helps other people out.

I just tried creating some mp3's from two adjacent tracks on a live album I've got.  I used EACv0.95prebeta3, encoding with LAME 3.92 set to --alt-preset extreme.  I had "add id3 tag" checked and also "use id3 v1.1 instead of id3 v1.0". I then played the files back in foobar 0.7 rc16.  They played WITH a gap between them. Ok, so I calculated the proper file length in samples and typed it in.  When I applied them the console screen popped up saying the padding was too big (or something like that).  It then changed the last three digits of the "desired length of track" samples to 888.  If I then changed it to 0, it reset to the original track length (in samples).

I then proceded to muck around in EAC and found out that by UNCHECKING "use id3 v1.1 instead of id3 v1.0" that the new files played back with NO gap. Hooray, we all can now have gapless mp3 playback.  But I guess if you use APE or other such tags there might not be problems either.

In summary, for those who want gapless playback of MP3's you need to use id3 tags V1.0 (i.e. with no track number).  I don't use APE tags or anything else so I don't know if they will work or not.  To correct a file with id3 v1.1 or later tags, I guess you would need to remove the tags and replace them with ID3V1.0 tags.

Hopefully this is of some help to people trying to get gapless playback.

discussion of fix mp3 header plugin

Reply #15
A sector on an audio CD is 2352 bytes, not 588.  From where does this 588 come?  Samples?  Oh, do mono CD tracks have 588 samples per sector?

discussion of fix mp3 header plugin

Reply #16
Yes, it means samples.  2352 bytes mean 18816 bits. For stereo, 588 16bit samples, in stereo, mean 588 x 16 x 2 == 18816 bits.

So a sector on a stereo CD can be said to be either 2352 bytes of PCM, or 588  16bit stereo samples.

discussion of fix mp3 header plugin

Reply #17
I have a question about the fix mp3 header plugin.

What do I do if I want to fix the vbr header, but want to leave the encoder delay/song length values etc. untouched? Is that possible with foobar2000's plugin?

discussion of fix mp3 header plugin

Reply #18
Quote
In summary, for those who want gapless playback of MP3's you need to use id3 tags V1.0 (i.e. with no track number).  I don't use APE tags or anything else so I don't know if they will work or not.  To correct a file with id3 v1.1 or later tags, I guess you would need to remove the tags and replace them with ID3V1.0 tags.

This is not true.
I use tracknumbers all the time in ID3 tags (therefore, I use ID3 1.1).
Gapless playback here (foobar 0.7.1 beta3).
Maybe you screwed up in some other EAC settings.
Or maybe I am just lucky (very small chance)
I'm the one in the picture, sitting on a giant cabbage in Mexico, circa 1978.
Reseñas de Rock en Español: www.estadogeneral.com

discussion of fix mp3 header plugin

Reply #19
I'm just stating what I found in my short tests with foobar2000 v0.7.0.  I'm pretty sure I didn't screw anything up in EAC.  I used EAC v0.95pb3.  Maybe I'll re-test when I have some more spare time.  Maybe EAC has bug or foobar2000 v0.7.1 has fixed a problem or maybe I did stuff up somewhere? I'm not sure.  Someone else can test if they want to confirm.

discussion of fix mp3 header plugin

Reply #20
hey

I've finally got to grips with this, and can now fix ANY of my mp3's, not just the LAME ones, with the limitation that they all have to have the same encoder delay (i.e. they were all encoded at the same time).

Thanks Peter...

I'm assuming that this information is updating the MP3 header, and therefore my work can't be undone by another program.

If anyone wants my tried and tested method, reply to this, and I'll knock up some instructions and a whizzy spreadsheet.
--Tosh

discussion of fix mp3 header plugin

Reply #21
Quote
If anyone wants my tried and tested method, reply to this, and I'll knock up some instructions and a whizzy spreadsheet.

Please, by all means 
I'm the one in the picture, sitting on a giant cabbage in Mexico, circa 1978.
Reseñas de Rock en Español: www.estadogeneral.com

discussion of fix mp3 header plugin

Reply #22
sorry, haven't been around for a few days

I'll post something soon
--Tosh

discussion of fix mp3 header plugin

Reply #23
Quote
sorry, haven't been around for a few days

I'll post something soon

Is that a promise? 

No, really, I hope you can post a little tutorial.
It would be very helpful.
I'm the one in the picture, sitting on a giant cabbage in Mexico, circa 1978.
Reseñas de Rock en Español: www.estadogeneral.com

discussion of fix mp3 header plugin

Reply #24
couldn't get any sleep, so here you go.

Firstly, this method only works for those CDs which have been ripped using an accurate ripper, and compressed with the same encoder.

Before you start.
You will need:

Foobar
Case's Gap Killer

In your DSP list, put the Gap Killer at the top of your DSPs, and load your playlist with the mp3's you want to make gapless.

Play your CD, and skip to near the end of each track. Listen to the transition, and if it isn't smooth - i.e. sounds jumpy or there are samples missing, then your underlying mp3's aren't accurate and this method can't help you.

If your mp3s are smooth (with Case's Gap Killer) you can continue.

Fixing the encoder delay.

Show the foobar Console. (components/show console.)

Play the first track and move the slider almost to the end, so that it flips to the next track. In the console you'll see how many samples the gap killer removed as below:

Code: [Select]
INFO (CORE) : location: "file://D:\_mp3\VA\Gatecrasher Resident Transmission 02 CD1\201.mp3" (0)
INFO (CORE) : opening file for playback :
INFO (CORE) : location: "file://D:\_mp3\VA\Gatecrasher Resident Transmission 02 CD1\202.mp3" (0)
INFO (foo_dsp_nogaps) : 887 samples removed (from end)
INFO (foo_dsp_nogaps) : 576 samples removed (from beginning)


This shows us that it removed 887 samples from the end of track 1, and 576 from the beginning of track 2. At the moment, we're only concerned with the samples removed from the beginning. Quickly skip to the end of all your tracks (in order) and make a quick table as below.

Code: [Select]
Track   samples removed 
       from beginning

1       576
2       576
3       578
4       576
5       575
6       578
7       254
8       577
9       577
10      576
11      576
12      578 (end of cd)


From this list, we can deduce that the most likely number of samples to remove from the beginning of each track is 576 - i.e. the encoder delay for each track is 576 samples.

Note, in my example above, track 7 hasn't got the correct encoder delay, and when playing this track there is a audible skip with missing samples (with gap killer). This track transition can't be fixed.

This is probably a LAME encoded album, but since foobar didn't detect the mp3 as being of accurate length, we're going to have to fix the mp3 headers. This method also works for Fhg and Xing encoded mp3s, as long as the delays are all close to each other.

Right click on each file in turn, and choose Fix MP3 header... Enter the same encoder delay for each one, and leave the desired length BLANK.

You've now fixed the encoder delay for all your mp3s.

Play the first track again, and move the slider near the end - check the console, you should now see entries like this:

Code: [Select]
INFO (CORE) : location: "file://D:\_mp3\VA\Gatecrasher Resident Transmission 02 CD1\201.mp3" (0)
INFO (CORE) : opening file for playback :
INFO (CORE) : location: "file://D:\_mp3\VA\Gatecrasher Resident Transmission 02 CD1\202.mp3" (0)
INFO (foo_dsp_nogaps) : 887 samples removed (from end)
INFO (CORE) : opening file for playback :
INFO (CORE) : location: "file://D:\_mp3\VA\Gatecrasher Resident Transmission 02 CD1\203.mp3" (0)
INFO (foo_dsp_nogaps) : 1200 samples removed (from end)
INFO (CORE) : opening file for playback :
INFO (CORE) : location: "file://D:\_mp3\VA\Gatecrasher Resident Transmission 02 CD1\204.mp3" (0)
INFO (foo_dsp_nogaps) : 1078 samples removed (from end)
INFO (CORE) : opening file for playback :
INFO (CORE) : location: "file://D:\_mp3\VA\Gatecrasher Resident Transmission 02 CD1\205.mp3" (0)
INFO (foo_dsp_nogaps) : 1078 samples removed (from end)

Note that Gap Killer is no longer removing samples from the beginning of the tracks.

Fixing the track length in samples.

Now you'll need my spreadsheet. Start the spreadsheet next to Foobar, so you can see both of them at the same time. The only value you're going to enter is the original length in BLUE.

Play the first track (showing the console), and flip to the next track - your output should say as follows:

INFO (foo_dsp_nogaps) : 887 samples removed (from end)

Right click the first track (you don't need to stop foobar, since it's now playing the second track), and choose Fix MP3 Header... Copy the length in samples from the dialog box, and paste into the spreadsheet. You can ALT-TAB between Excel and Foobar, leaving the cursors in the same place.

In the spreadsheet, you're looking for the track length in samples (RED values), which is closest to the output of Gap Killer. Gap Killer removed 887 samples, and the corresponding track length is 13732152 (in my example). ALT-TAB back to foobar, and edit the desired length. Hint, usually only the last four digits change.

Press OK to save your new length, and double click the first track again. Skip to the end, and your mp3s should now be gapless!

Repeat this for the rest of your mp3s, and your work is done!

You can now remove Gap Killer from the active DSPs and check your work.

Troubleshooting

If this doesn't work for you, your mp3s probably don't sound right with gap killer anyway, therefore you're not going to able to fix your mp3s. Sorry. Also, if you've got an album collected from various sources, and they don't all have the same encoder delay, you can try setting them individually, but whenever I've done this, I've run into problems.

Tips for Writing CDs with Nero.

Some of my albums only have a few gapless tracks between some songs - don't waste your time fixing all of the tracks, only do those that are needed.

My reason for doing this, was so that I could write gapless CDs for the Car. If you're doing the same, and you're using Nero, I suggest you do the following.

When you're outputting your mp3s to WAVs using the Diskwriter, use the output file name formatting as %artist% - %title%.

To create an Audio CD in Nero, sort your directory by date/time, and drag your WAVs into the compilation. Your Artist and Track Title fields will be properly formatted for CD-TEXT. You just need to highlight tracks 2-end, double click and set track gap to 0.

Press Burn, set the Artist, Album Name, Speed and Go.

ps. where can I upload the spreadsheet?
--Tosh