Skip to main content
Topic: Incorrect Bitrate displayed for VBR files (Read 4769 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Incorrect Bitrate displayed for VBR files

Hi everyone,

I have an issue with my MP3s in VBR that, I know, many have asked about.

The bitrate in many music players whether in PC (VLC etc..) or in Android, correspond to the first frame of the MP3 (I checked it with MPEG Audio Info) and as you should know, it's often 128kbps (or 32/64). It corresponds to the Xing header if i'm not mistaken, and isn't representative of the average bitrate (that several music players managed to display, as Winamp, Foobar2000, FFMpeg...)

What I've tried is fixing VBR with all the softwares that I found on the forum (Foobar2000, VBRFix, MP3Diags, MP3Val ...) but the only thing these softwares did is changing the bitrate for the first frame (e.g if it was 128kbps, its now 64kbps).
So these software make the thing worse since I now see a lower bitrate in my music players...

As I want to see the correct bitrate without an external software/app I wanted to know the following:

Is there any way to modify the Xing Header, the first frame of a song I guess, in order to make it match the average bitrate of my song. So that any music player will display the correct bitrate (Whether those which calculate it, or those which read the first frame). I mean, VBRFix and the others are able to change the number of a frame so why not after all..

I hope I clearly explained my request.

Thank you  :)

Re: Incorrect Bitrate displayed for VBR files

Reply #1
Personne ?  :(

Re: Incorrect Bitrate displayed for VBR files

Reply #2
I meant "No one", I'm so tired that I spoke french on an english topic  :D

Re: Incorrect Bitrate displayed for VBR files

Reply #3
VBRfix or MP3 Diags has always fixed "problem files" for me.    The problems I had related to incorrect playing-time or incorrect time-remaining, and I don't know if the average bitrate was correct or not.

I also don't know what version of LAME I was using to create these "problem files", but it's been fixed for a long-long-time and I no longer get problem files.

You could probably fix (or create) the Xing header manually one at a time with a hex editor, but you'd have to research the format.     I opened an MP3 with a hex editor and I found the text "Xing" near the end of the file, but I have no idea what the following hex (binary) data means.

...OK, I found this.    It doesn't look like the Xing header directly stores you the average bitrate, but maybe  it's presence indicates VBR so the player-software knows it should calculate it.

Re: Incorrect Bitrate displayed for VBR files

Reply #4

I don't know of any tool that generates the first frame with a bitrate approximate to the average bitrate. Generally, since that frame is only needed to store some information, it is sized accordingly. It should not be too difficult, but probably there was no reason.

DVDdoug: He is not talking about programs not reading the tag properly, but actually, not reading the tag at all and basing it on the first frame bitrate.  I.e. dumb players.

Re: Incorrect Bitrate displayed for VBR files

Reply #5

You could probably fix (or create) the Xing header manually one at a time with a hex editor, but you'd have to research the format.     I opened an MP3 with a hex editor and I found the text "Xing" near the end of the file, but I have no idea what the following hex (binary) data means.


Even if its possible to do so it'd be too difficult and boring to edit MP3s one by one, especially when you have 2000 files  :)


I.e. dumb players.


I'd rather say dumb encoders. I mean its a challlenge for players to display the average bitrate (VLC don't do that in 2017..) but its easy for an encoder to write a number in a frame (btw I tested on LAME and others alternatives, its the same.)

Its so ridiculous to see 64kbps or 128kbps when you are listening to a HQ song in V0, and maybe you want to delete it or look for a better quality if your aren't aware of that...

Anyway, if someone have a solution for that eternal issue it would be so cool  :))


Re: Incorrect Bitrate displayed for VBR files

Reply #6
AFAIK frame sizes in MP3 format can't be arbitrary.
Quote from LAME help:
Code: [Select]
MPEG-1   layer III sample frequencies (kHz):  32  48  44.1
bitrates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320

Re: Incorrect Bitrate displayed for VBR files

Reply #7
AFAIK frame sizes in MP3 format can't be arbitrary.
Quote from LAME help:
Code: [Select]
MPEG-1   layer III sample frequencies (kHz):  32  48  44.1
bitrates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320


Suppose it is as you said, its still OK to me, as long as the encoder choose the closest frame to the average bitrate. If the average is 173kbps it displays 160. If its 243kbps it shows 256..

Re: Incorrect Bitrate displayed for VBR files

Reply #8

I.e. dumb players.


I'd rather say dumb encoders. I mean its a challlenge for players to display the average bitrate (VLC don't do that in 2017..) but its easy for an encoder to write a number in a frame (btw I tested on LAME and others alternatives, its the same.)

The encoder is fine, I think all encoders in the last 15 years write the correct bitrate to the header: 

https://www.codeproject.com/Articles/8295/MPEG-Audio-Frame-Header#VBRHeaders

It sounds like you're just using software that doesn't understand how to read mp3 headers correctly.

I think the easiest solution would be to use software that doesn't have this limitation.  If you can't do that, I'm not sure if there is an easy work around.  You could in theory design an encoder that set the first frame to have the average bitrate, but that would be complex since you don't know the average bitrate until after the entire file is encoded.  I think you could go back and transcode just the first frame to a new frame that had the closest allowed bitrate to the true average, but I have never seen software to do that. 

Re: Incorrect Bitrate displayed for VBR files

Reply #9
Quote
The encoder is fine, I think all encoders in the last 15 years write the correct bitrate to the header: 

https://www.codeproject.com/Articles/8295/MPEG-Audio-Frame-Header#VBRHeaders

It sounds like you're just using software that doesn't understand how to read mp3 headers correctly.

I read your link and I don't understand the way you did :

"To get this average bitrate, you must go through all the frames in the file and calculate it, by summarizing the bitrates of each frame and dividing it through the number of frames. Because this isn't a good practice (very slow), there exists additional VBR headers within the data section of the first frame (after the frame header). They contain the total number of frames in the file from which you can calculate the duration in seconds with the following formula"

It speaks about duration calculation apparently

Quote
I think the easiest solution would be to use software that doesn't have this limitation.

I would never change my android music player, its the best to me :p
For Windows, yes, VLC isn't that good, I personnaly use MPC which is good for displaying bitrate.

So I'd rather think that several apps and softwares calculate manually the bitrate thanks to the number of frames of the header.

Re: Incorrect Bitrate displayed for VBR files

Reply #10
I read your link and I don't understand the way you did :

"To get this average bitrate, you must go through all the frames in the file and calculate it, by summarizing the bitrates of each frame and dividing it through the number of frames. Because this isn't a good practice (very slow), there exists additional VBR headers within the data section of the first frame (after the frame header). They contain the total number of frames in the file from which you can calculate the duration in seconds with the following formula"
Seems pretty clear to me?  You read the header which tells you what you need to calculate the true bitrate. 

So I'd rather think that several apps and software calculate manually the bitrate thanks to the numer of frames of the header.

Sounds like you've found yourself a fun programming project then.  Design an app that can repack/transcode the first frame(s) to match the value in the header. 



Re: Incorrect Bitrate displayed for VBR files

Reply #13
Are you sure that the 64 is from the header and not just a dumb program (not) reading it?

(When it comes to mp3packer: does it make a difference whether you use -r or -R?)


Re: Incorrect Bitrate displayed for VBR files

Reply #15
Are you sure that the 64 is from the header and not just a dumb program (not) reading it?

(When it comes to mp3packer: does it make a difference whether you use -r or -R?)

I tried both and it's still 64kbps.

just a dumb program (not) reading it?
That's exactly the problem.

Could someone provide me a software that can show the header, without any calculation.
For instance something that analyze the entire mp3 file and the header with it.

I'm confused right now, do the softwares like media info, foobar, etc READ the bitrate from the header, or CALCULATE it from all the frames ?


Re: Incorrect Bitrate displayed for VBR files

Reply #16
What is the name of the Android Music Player APP?



Re: Incorrect Bitrate displayed for VBR files

Reply #19
Relevant thread:

https://github.com/vanilla-music/vanilla/issues/620

Developer there says you gave him a file with a bad header which is why Android couldn't calculate the real bitrate.

No, the fact is that I gave him a file that was in 243kbps (true average bitrate) in FFMpeg, Foobar, Black player (android), Phonograph (android) etc etc.

If the header where bad, then how come these softwares/apps above managed to display the right number. Also if I fix the mp3 with vbrfix, it changes from 128 to 64 in the players like vlc, BUT in those that were displaying the correct bitrate it make no difference with a "non-fixed" mp3 (243kbps in any case).

There is still many players as VLC or Vanilla that show 128kbps..
So my question is the same : is it a calculation of the bitrate that require more complex coding or aproriate libraries or is it just a reading of an header (and so VLC, Vanilla etc can't read it because 128 come from the first frame and no from the header).

Re: Incorrect Bitrate displayed for VBR files

Reply #20
If you think he's wrong, you probably should have asked for an explanation.

You can take a look at how the bitrate is stored using the link I posted above. The exact way depends on what header is present, but most (all?) involve dividing the audio data length in bytes by the length in seconds.


Re: Incorrect Bitrate displayed for VBR files

Reply #22
Quote
Just tried that Vanilla APP on my Samsung Galaxy Tab (Android 6), it doesn't show me any bitrate at all. At least song duration is correct and seeking works too.

Its because you have to long press the artist/album name in playback view (I mean when you are inside your song with the seek bar, at the top) , then the details of the song appear.
Please tell me what you have.

Re: Incorrect Bitrate displayed for VBR files

Reply #23
If you think he's wrong, you probably should have asked for an explanation.

He said that the mp3 header says 128kbps (I understood that the header is the first frame, and the first frame is 128kbps, as I saw in many softwares).
If the first frame = the header = 128kbps then how come LAME isn't the one to blame ? Is the first frame composed of a data section + a bit rate (128kbps) and some players read only the bitrate of the frame instead of going through the data section? (its what I understand from your link)

I mean, if you say that MY files have bad headers and that the bitrate is read from the header (first frame), then every softwares would display 128kbps (unless the data section is separate from the nitrate of the frame as I asked above).

I can bet that if you send me any vbr file, it will show 128 or 64 kbps (or even 32) though, we can try.

Re: Incorrect Bitrate displayed for VBR files

Reply #24
andiandi: I don't really know what the knowledge of that developer is (and what libraries , if any, he uses to parse the data), but he is right and wrong at the same time.

Let me explain a bit about frames and bits and all that:

The MP3 format defines a structure of packets that are stored one after another.
Each one of these packecks, can have one of 16 predefined sizes, ( the fixed bitrates like 128, 160 192, etc that the format can have at the packet level, which also depend on which layer the format is in, but that's for another subject).
The duration of each of these packets is also fixed (it doesn't matter which bitrate it has, there is a fixed amount of milliseconds in each packet, depending on the samplerate used).

Now, going back in time, when MP3 codec developers started to push the format capabilities, one of them, Xing technologies, invented a "tag" that their encoder wrote into the first packet of the MP3 file, the XING VBR tag/header. This tag had additional information about the total track duration and also a seek table, so that seeking would not need reading all the packets to know where to seek to (remember , VBR = different packet sizes).

Later on, LAME incorporated this tag, and extended it for other purposes, like sample accurate length and codec information.

On another front, the inventors of MP3, frauhoffer, added an alternative tag to their encoder, the VBRi, which is also written to the first packet of the MP3, and has a similar amount of information (the format is shown in the link that you were given earlier in this thread).

So, if the developer of Vanilla is telling you that the MP3 frame header says 128, then, he is correct, but he is missing completely the point: IF the first frame of the MP3 contains a VBRi or XING tag inside, that tag has to be read in order to give the correct information.

 
SimplePortal 1.0.0 RC1 © 2008-2018