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.7k stars 6.02k forks source link

Unable to load/play file with h264 or h265 extention #8464

Closed purvagevaria closed 3 years ago

purvagevaria commented 3 years ago

Goal to be achieved There is two sample files which are having extension h265 and h265. Links of sample files. I want to load both or any of this in Exo player. https://drive.google.com/drive/folders/188E8HOMXnBRsE_dLGEYBinLgPK651k24?usp=sharing

Issue description I am trying to load the file please download both the sample and load this file in Exo. Below is my code sample

simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(this) val rawDataSource = RawResourceDataSource(this) rawDataSource.open(DataSpec(RawResourceDataSource.buildRawResourceUri(R.raw.test0))) val mediaSource = ExtractorMediaSource.Factory({ rawDataSource }) .createMediaSource(rawDataSource.uri) simpleExoPlayer.prepare(mediaSource, false, false) simpleExoPlayer.playWhenReady = true playerView.setShutterBackgroundColor(Color.TRANSPARENT) playerView.player = simpleExoPlayer playerView.requestFocus()

Exo library version : 2.10.4

At the end, I got the below error ExoPlayerImplInternal: Source error. com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (MatroskaExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, Ac3Extractor, TsExtractor, FlvExtractor, OggExtractor, PsExtractor, WavExtractor, AmrExtractor, Ac4Extractor, FlacExtractor) could read the stream.

I checked the supported media format but the h265 file is not defined but h264 is defined as a supported media format then also I am not able to load both of these files.

I believe below are the class which may support this file formats https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/extractor/ts/H265Reader.html - Parses a continuous H.265 byte stream and extracts individual frames. https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/extractor/ts/TsExtractor.html

1) So is there anything which I am missing or am I doing anything wrong in this? If something is wrong with my code then is there any code sample available which can help me to resolve the issue?

https://exoplayer.dev/supported-formats.html#sample-formats here it's clearly mentioned that my h264 file is supported.

2) If possible please list down file extensions that are supported by exo https://exoplayer.dev/supported-formats.html#progressive-container-formats should I consider this as supported file extensions are supported? I am developing an app that is specific to file extensions so please do mention it so that I can have a clear idea about those.

andrewlewis commented 3 years ago

This looks related to your previous issue #8439, except that it includes H.264. Please read the start of https://exoplayer.dev/supported-formats.html especially about the distinction between container formats and sample formats. Just because H.264/AVC samples are supported it doesn't imply that the container you are using is supported. I am assuming that your H.264/AVC stream is an Annex B stream like the H.265/HEVC stream you linked to on the other bug.

https://exoplayer.dev/supported-formats.html#progressive-container-formats lists the supported containers, though note that these may come with different file extensions (ExoPlayer reads the start of the file to determine whether the container is supported, rather than simply looking at the file extension).

purvagevaria commented 3 years ago

This looks related to your previous issue #8439, except that it includes H.264. Please read the start of https://exoplayer.dev/supported-formats.html especially about the distinction between container formats and sample formats. Just because H.264/AVC samples are supported it doesn't imply that the container you are using is supported. I am assuming that your H.264/AVC stream is an Annex B stream like the H.265/HEVC stream you linked to on the other bug.

https://exoplayer.dev/supported-formats.html#progressive-container-formats lists the supported containers, though note that these may come with different file extensions (ExoPlayer reads the start of the file to determine whether the container is supported, rather than simply looking at the file extension).

@andrewlewis streaming is in our hands so any suggestions to change the format from the streaming side only? I will receive h264/h265 streams and I will load them into my exo.