Skip to content

Match MediaPlayer behavior of skipping unexpected data the start of an MP3 #5718

Closed

Description

@theboubougne

I'm trying to play the following file with EXOPlayer 2.9.6 and it fails with the following exception:
UnrecognizedInputFormatException

http://podcastdownload.faithcomesbyhearing.com/mp3.php/ENGKJVC2DA/A01___01_Genesis_____ENGKJVC2DA.mp3

I experienced the same thing on every test devices, while the device MediaPlayer was able to play the file without any issue (Tested on Android 8, 9, Q on Pixel 2, 3 and Samsung S8)

It fails both trying to stream the file or play a local copy

I checked the file encoding and didn't see anything specific
Audio

Format : | MPEG Audio
Format version : | Version 2
Format profile : | Layer 3
Format settings : | Joint stereo / Intensity Stereo + MS Stereo
Duration : | 5 min 13 s
Bit rate mode : | Constant
Bit rate : | 64.0 kb/s
Channel(s) : | 2 channels
Sampling rate : | 22.05 kHz
Frame rate : | 38.281 FPS (576 SPF)
Compression mode : | Lossy
Stream size : | 2.39 MiB (97%)

Stack

com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (MatroskaExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, Ac3Extractor, TsExtractor, FlvExtractor, OggExtractor, PsExtractor, WavExtractor, AmrExtractor) could read the stream.
    at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractorHolder.selectExtractor(ExtractorMediaPeriod.java:973)
    at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:891)
    at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:914)

Activity

  1. google-oss-bot commented on Apr 2, 2019

    @google-oss-bot
    Collaborator

    This issue does not seem to follow the issue template. Make sure you provide all the required information.

  2. andrewlewis commented on Apr 2, 2019

    @andrewlewis
    Collaborator

    It looks like the stream is prefixed with some text data before the ID3 header appears at offset 0x125.

  3. self-assigned this
    on Apr 2, 2019
  4. theboubougne commented on Apr 2, 2019

    @theboubougne
    Author

    This should be ignored by the Mp3Extractor as the MediaPlayer seems to already do this

  5. andrewlewis commented on Apr 4, 2019

    @andrewlewis
    Collaborator

    I'll tentatively mark this as a low priority enhancement. Identifying media prefixed by arbitrary other data doesn't seem particularly useful, nor is it possible to do it efficiently in general, but getting the same behavior as the platform player is reasonable.

    In the short term I think the best options are to fix the media, or write a custom data source that identifies the actual start of ID3 data (assuming that's always expected) and throws away anything before that.

  6. changed the title [-]UnrecognizedInputFormatException while trying to play a MP3[/-] [+]Match MediaPlayer behavior of skipping unexpected data the start of an MP3[/+] on Apr 4, 2019
  7. theboubougne commented on Apr 4, 2019

    @theboubougne
    Author
  8. 1 remaining item

  9. theboubougne commented on Apr 5, 2019

    @theboubougne
    Author
  10. ojw28 commented on Apr 7, 2019

    @ojw28
    Contributor

    That argument only really stacks up if there are a significant number of problematic files in the wild. If you've come across a single file that has this problem, which doesn't even play properly on some other platforms, then it really doesn't justify the extra engineering effort of keeping two players around in your app, and neither does it justify effort on our side to accommodate this single file. If the problem is more widespread, it would be good to know what the source of these files and some idea of how many streams are affected. Else this remains a low priority issue.

  11. theboubougne commented on Nov 13, 2019

    @theboubougne
    Author

    Looks like the issue still exists with 2.10.7
    I can reproduce it with the following stream: http://rogers-hls.leanstream.co/rogers/gra977.stream/playlist.m3u8

  12. halaei commented on Apr 4, 2020

    @halaei

    Maybe this ffmpeg commit and the description can help:
    FFmpeg/FFmpeg@2b3e9bb

    avformat/mp3: skip junk at the beginning of mp3 files

    Apparently it can happen that a mp3 file has junk data between id3 tag
    and actual mp3 data. Skip this to avoid outputting nonsense timestamps.
    (Two packets had the same timestamps, because the mp3 parser failed to
    compute a frame duration.)
    In this case, the junk consisted of 1044 bytes of zero, which
    incidentally is the same size as normal mp3 frames in this stream. I
    suspect the mp3 was edited with some tool which wiped the Xing/LAME
    headers. Data near the end of the file suggests it was encoded with
    "LAME3.97", but the normal Xing/LAME headers are missing. So this could
    be "normal". mpg123 also attempts to skip at least 64KB of junk data by
    scanning for headers.

  13. andrewlewis commented on Apr 6, 2020

    @andrewlewis
    Collaborator

    @kim-vde It may be interesting to consider this in the context of the sniffing improvements you are working on. I guess if MP3 ends up at the end of the list of extractors we can read ahead further during sniffing before giving up.

  14. kim-vde commented on Dec 8, 2020

    @kim-vde
    Contributor

    As mentioned in #8317 (comment), we should consider supporting parsing of ID3 data that is not at the start of the file.

  15. icbaker commented on Jul 29, 2025

    @icbaker
    Collaborator

    I think this should be handled by the commit linked above.

  16. locked and limited conversation to collaborators on Sep 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions