-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propagate bitrate from MP3 files into Format (maybe only CBR ones?) #11124
Comments
Do you observe issues on the actual audio you listen to? The log you refer to is coming from the platform and is probably printing a default value because the player is not setting a bitrate for audio formats. |
I can't tell what bitrate the play is playing because |
ExoPlayer does not alter with the media bitrate and just feeds the audio to the device. The log is coming from the platform amd the value is probably a default expected bitrate printed because the player does not define one when setting the decoder. If you prefer, can you share the mp3 file with us so that we can test too? |
Here is the audio file: Dreamer 320kbps - Alan Walker The actual audio URL involves Token verification and App Check verification so I can't create an unauthorized URL for sharing. Instead, if you wouldn't bother, please take a quick look at my actual app: YouWave - Google Play. Scrolling to the bottom, you will find some NCS music tracks on the home page. |
I played the file, and as I described above, the player is not reading the bitrate from file header and neither sets it to MediaCodec. The file is passed straight to the device. |
So that the audio is played at 320kbps successfully? |
This information should be taken while parsing the file, which apparently is not picked up the specific mp3 file. There is not API at the moment. @rohitjoins do you think it's feasible to parse bitrate from the mp3 container? |
The provided file is constant bitrate, so the bitrate can be determined by simply doing It's not clear to me whether there's any value in ExoPlayer doing this (since an app can do it so easily themselves). We generally don't parse bitrates from progressive containers, since we only use the bitrate for selecting different tracks in adaptive media. |
This is a very nice idea but how do I get |
Ah yeah, getting the file length in a general way is hard (I was assuming you had the file locally). I looked into modifying Lines 271 to 278 in cf49175
Unfortunately that's just the bitrate of the first frame we've synchronized on, and we don't know if the file is VBR or CBR. If it's CBR we can know that every frame will have the same bitrate so it's safe/sensible to put it into the I tried naively checking if the file is CBR by checking tl;dr we can keep this open as a low-priority request, but it's not clear how to easily do it in a robust way, and i'm afraid we're unlikely to work on it (since, as above, parsing bitrates from progressive containers is generally not important for ExoPlayer since we don't use the information for anything). |
I tried that |
I see the 320kB bitrate returned from
You're welcome to make this change in a local fork of ExoPlayer if you want to assume that you always play CBR MP3 files. |
Actually, I'm using the library |
Well then you filed in the wrong issue tracker (and ignored the prompt to file all issues, even ExoPlayer related ones, in https://github.com/androidx/media/issues)... The equivalent link for forking and depending locally is here: https://github.com/androidx/media/blob/release/README.md#locally |
For the record here's what I use on my version that for now covers all the cases I'm aware of. int bitrate;
long length = input.getLength();
long duration = seeker.getDurationUs();
if (seeker instanceof VbriSeeker) {
if (length != C.LENGTH_UNSET && duration != C.TIME_UNSET && duration != 0 ) {
bitrate = (int) ((length * 8) / (duration / 1000)) * 1000;
} else {
bitrate = 0;
}
} else if (seeker instanceof XingSeeker) {
if (length != C.LENGTH_UNSET && duration != C.TIME_UNSET && duration != 0) {
bitrate = (int) ((length * 8) / (duration / 1000)) * 1000;
} else {
bitrate = 0;
}
} else {
bitrate = synchronizedHeader.bitrate;
} then |
Bug
You can clearly see this line:
int32_t bitrate = 64000
.The text was updated successfully, but these errors were encountered: