-
Notifications
You must be signed in to change notification settings - Fork 413
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
ExoPlayer wrongly decode some MP3 file #1376
Comments
By chance I happened to test this file in the 1.2.1 version of the demo app, and there I see a duration of 7:17 and playback stops at 7:18 (this was after seeking, so the mismatch is likely due to MP3 + Xing header resulting in inherently innacurate seeking). At 1.3.0 I see the issue you describe, the duration is shown as 1:12:51. The culprit is this change: 4061d476a14314867da2f74ba7049c85568b56eb\ Reverting that on top of 1.3.0 restores the duration to 7:17. The issue is that this file is variable bit rate (VBR) (as reported by This results in calculating the duration of the stream by assuming all frames are the same size as the first frame after the media/libraries/extractor/src/main/java/androidx/media3/extractor/mp3/Mp3Extractor.java Lines 540 to 543 in d13a0f4
media/libraries/extractor/src/main/java/androidx/media3/extractor/mp3/Mp3Extractor.java Lines 566 to 583 in d13a0f4
In this case, the file seems to have a single 104 byte, 32kbps frame immediately after the Implementing the TODO related to deriving the duration from the I will work on tidying up this change, and sending it for internal review. |
Correction/clarification - all the 1044/1045 byte frames are 320kbps, so CBR - the one byte difference comes from the padding value in the frame header. |
Thanks for the details and the probable fix. |
ExoPlayer complains about this file for another, related, reason: the Even if we consider that the
ExoPlayer warns about this mismatch at 1.2.1 where the Xing frame is used for duration and seeking (after this warning, it uses the
Digging into the file with $ ffprobe -show_packets 003.mp3
# only showing last packet and eliding irrelevant values
...
[PACKET]
...
size=1045
pos=17486394
...
[/PACKET]
The data after this point seems to be some album artwork, as you can see from an ASCII interpretation of a snippet of the hex dump at this point:
The "use |
For the record those are APEv1 tags.
In case this impact other places too. |
Ah thanks, that's useful context. I also did a bit of digging into this one-off 104 byte (32kbps) frame at the start of the stream, and noticed it has a |
Seems I found you a nice file for the test collection :) |
This shows ExoPlayer currently wrongly reports the duration of this sample, because it assumes every frame is 32kbps (104 bytes) due to the `PCUT` frame immediately after the `Info` frame. A follow-up change will modify `Info` frame handling to resolve this issue. This sample was crafted using a hex editor to insert the additional `PCUT` frame (the pattern of `null` and `x` is taken from the sample file in Issue: #1376, the header is modified to set the channel count to 1 to match the rest of the file), and then update the frame count and data size of the `Info` header to match. Issue: #1376 PiperOrigin-RevId: 635772837
`Info` header is used for CBR files, but in some cases not **every** frame in these files is the same size. This change stops using the single frame after the `Info` frame as the 'template' (and assuming all subsequent frames are the same size/bitrate), and instead derives the bitrate from fields in the `Info` header. This works for files which are 'almost' constant bitrate, like the one in Issue: #1376 where every frame is either 1044 or 1045 bytes except the one immediately after the `Info` frame which is 104 bytes (32kbps), resulting in a wildly incorrect duration calculation. PiperOrigin-RevId: 636151605
This should be resolved by the commits linked above. I considered some other changes and ultimately rejected them:
|
Version
Media3 1.3.1
More version details
No response
Devices that reproduce the issue
Any
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
Play attached file, it will show a duration of more than 1 hours and will keep playing without sound for that duration.
The file plays well in other players and the actual duration is properly reported by taglib or ffmpeg or Android.
Expected result
File have correct duration and does not play without sound for 1 hour.
Note that I had a few report of this over the years from different users.
Actual result
The file duration is completely off and it keeps playing with no sound for that duration.
Media
003.zip
Bug Report
adb bugreport
to android-media-github@google.com after filing this issue.The text was updated successfully, but these errors were encountered: