Unable to play HEVC/h265 videos on exoplayer

Viewed 544

I am building a video player in the exoplayer library in android. I am unable to play h265 videos on all the devices. When I use another media player, e.g. MX Player, I am able to play the same media on the same devices. Below is the code for initializing the player written in Kotlin.

val trackSelector = DefaultTrackSelector(this)
    trackSelector.parameters = DefaultTrackSelector.ParametersBuilder(this)
        .setRendererDisabled(C.TRACK_TYPE_VIDEO, false)
        .build()

    val dataSourceFactory: DataSource.Factory = DefaultDataSource.Factory(this)
    prepareMediaItems(hashMap)

    val extractorsFactory = DefaultExtractorsFactory()
        .setTsExtractorFlags(DefaultTsPayloadReaderFactory.FLAG_ALLOW_NON_IDR_KEYFRAMES)


    val renderersFactory: RenderersFactory = DefaultRenderersFactory(this)
        .setExtensionRendererMode( if (isHardwareDecodingEnabled)  DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON else  DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER)

    player = ExoPlayer.Builder(this, renderersFactory)
        .setMediaSourceFactory(DefaultMediaSourceFactory(dataSourceFactory, extractorsFactory))
        .setTrackSelector(trackSelector)
        .build()

The video tries to play the video by loading the first frame and then keeps loading. This is the error i get in the Logcat:

E/ACodec: [OMX.google.hevc.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
I/ACodec: codec does not support config priority (err -1010)
1 Answers

As far as I know you won't be able to get all H265 videos to work across all devices (including older versions of Android) without embedding some decoding libraries in your app. Re-encoding your videos using (for instance) H264 Baseline Codec would work if that's an option?

Related