You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mp3Extractor: Support files with (slightly) incorrectly declared ID3 tag lengths #811
Media3 pre-release (alpha, beta or RC not in this list)
More version details
Any version but tested with 1.2.0
Devices that reproduce the issue
All
Devices that do not reproduce the issue
None
Reproducible in the demo app?
Yes
Reproduction steps
Try to play a file with multiple large ID3 headers.
Like a small ID3 v1 header followed by an ID3 header larger than 32k
The extractor sniff will fail because only the first ID3 header is taken in account and skipped, so the sniff does not reach the proper frames before the end of the second ID3 header.
Second header that should either be skipped or handled for the gapless data / metadata don't know if there should be a priorisation of ID3 v2 tags over v1 when both are present.
Expected result
The media should play
Actual result
The media does not play because the sniff return false due to large second ID3 header.
ExoPlayer's Id3Peeker does try to read multiple ID3 tags with the while loop in Id3Peeker (in order to handle the case you describe). We try and advance to the start of the next tag with this line:
if (scratch.readUnsignedInt24() != Id3Decoder.ID3_TAG) {
// Not an ID3 tag.
break;
}
The first ID3 tag in this file represents its length as 0x00001070, which is a 'synch safe' int where the MSB of each byte is zero (and ignored), so this evaluates to 2160 in decimal. This is the length without the 10 byte ID3 header (but does include padding) [1], so the next ID3 tag should start at byte 2170, but in fact it starts at 2171.
We can add some fuzziness to the search for the next ID3 tag, but this media is not spec-compliant, so marking this as a feature request rather than a bug.
The ID3v2 tag size is the size of the complete tag after unsychronisation, including padding, excluding the header but not excluding the extended header (total tag size - 10).
changed the title [-]Mp3Extractor do not properly support multiple ID3 headers at file start[/-][+]Mp3Extractor: Support files with (slightly) incorrectly declared ID3 tag lengths[/+]on Jul 22, 2025
Activity
rohitjoins commentedon Nov 15, 2023
Hi @Tolriq,
Can you please send the media via email for me to take a look?
Tolriq commentedon Nov 15, 2023
Sent.
Tolriq commentedon Jul 21, 2025
Small why not bump. Still an issue. My local hack is just an hack not good enough to upstream.
icbaker commentedon Jul 22, 2025
ExoPlayer's
Id3Peekerdoes try to read multiple ID3 tags with thewhileloop inId3Peeker(in order to handle the case you describe). We try and advance to the start of the next tag with this line:media/libraries/extractor/src/main/java/androidx/media3/extractor/Id3Peeker.java
Line 78 in ae9a233
In the case of the provided file, this advances one byte too few, so this check fails (because we read
0x094944 = <TAB>IDinstead of0x494443 = ID3).media/libraries/extractor/src/main/java/androidx/media3/extractor/Id3Peeker.java
Lines 63 to 66 in ae9a233
The first ID3 tag in this file represents its length as
0x00001070, which is a 'synch safe' int where the MSB of each byte is zero (and ignored), so this evaluates to 2160 in decimal. This is the length without the 10 byte ID3 header (but does include padding) [1], so the next ID3 tag should start at byte 2170, but in fact it starts at 2171.We can add some fuzziness to the search for the next ID3 tag, but this media is not spec-compliant, so marking this as a feature request rather than a bug.
[1] From https://id3.org/d3v2.3.0
[-]Mp3Extractor do not properly support multiple ID3 headers at file start[/-][+]Mp3Extractor: Support files with (slightly) incorrectly declared ID3 tag lengths[/+]Add some fuzziness to Mp3Extractor's ID3 tag searching
icbaker commentedon Jul 29, 2025
This is fixed by the commit linked above.
Add some fuzziness to Mp3Extractor's ID3 tag searching