google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.71k stars 6.02k forks source link

Mp3Extractor used for .flac instead of FlacExtractor #6941

Closed ivan2311 closed 4 years ago

ivan2311 commented 4 years ago

I'm using Flac Extension to play .flac files via ExoPlayer. ExoPlayer has basic setup so FlacExtractor should be automatically used when .flac is played. To be exact, I'm using DefaultExtractorsFactory which supports 14 different Extractors, including Mp3Extractor and FlacExtractor.

Almost every .flac file plays ok, except one. For this one .flac file, Mp3Extractor.sniff returns true when ExtractorHolder.selectExtractor is called, so Mp3Extractor gets selected to be used to play this .flac file. Also, if I just remove Mp3Extractor from the list of extractors, or move FlacExtractor to be before Mp3Extractor in the list of extractors, FlacExtractor gets selected and that .flac file plays normally.

So, my question is: can I just move FlacExtractor to be used before Mp3Extractor inside ExtractorsFactory.createExtractors? Are there any possible side effects? For example, if I have .mp3 file and FlacExtractor now gets selected somehow...

ojw28 commented 4 years ago

Could you please share the problematic file, so we can see why Mp3Extractor thinks that it's an MP3 file?

ivan2311 commented 4 years ago

@ojw28 Unfortunately, I can't share that file currently. I'll see if I can share some sample file that has the same issue, so you could investigate Mp3Extractor. In the meantime, can you please help me with my question? Is that safe to do?

ojw28 commented 4 years ago

I think it's probably safe. @kim-vde might have further thoughts. Note that there's a tracking issue for determining what the best order of extractors really is, which is https://github.com/google/ExoPlayer/issues/6410.

kim-vde commented 4 years ago

I would be curious to have an example of a FLAC file for which the MP3 sniffing returns true. It would be interesting to understand exactly what happens to potentially prevent it.

I think it is indeed safe to put the FLAC extractor before the MP3 extractor. The only way an MP3 file could be interpreted as a FLAC file is if the first 4 bytes following the ID3 data are "fLaC" in ASCII (in hexadecimal, this corresponds to 0x664C6143), which seems unlikely. This could only happen if the MP3 starts by junk data because a valid MP3 header should start with 11 set bits.

ivan2311 commented 4 years ago

Thanks @ojw28 and @kim-vde for the explanation. As for the .flac file for which the MP3 sniffing returns true, I'll try to share it with you ASAP. In the meantime you can close this issue and I can reopen it when I have some sample file for testing.

google-oss-bot commented 4 years ago

Hey @ivan2311. We need more information to resolve this issue but there hasn't been an update in 14 days. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 4 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@ivan2311 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

kim-vde commented 4 years ago

Could you provide the size of the FLAC file for which the Mp3Extractor was selected, to help me understand what might have happened?