media
media copied to clipboard
Decoder init failed error on some AndroidTV devices
Version
ExoPlayer 2.18.5
More version details
I'm following this doc(https://developer.android.com/guide/topics/media/exoplayer/ad-insertion#client-using-third-party) implementing a custom AdsLoader that wraps our ads SDK. Previously, we implemented seamless content and ad switching using two ExoPlayer instances. Now, we have achieved the same seamless switching using a custom AdsLoader with a single-player instance. We tested this solution on the production environment and put it under an experiment. We noticed that this approach resulted in a significant increase in "Decoder init failed" errors on Android TV, roughly seven times more than before.
Error cause Decoder init failed: OMX.amlogic.hevc.decoder.awesome2.secure, Format(1, null, null, video/hevc, hvc1.1.6.L90.90, 1205048, null, [854, 480, 23.974], [-1, -1]) Error message com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/hevc, hvc1.1.6.L90.90, 1205048, null, [854, 480, 23.974], [-1, -1]), format_supported=YES
Below is the code I used to build the DrmConfiguration
val drmConfiguration = MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID)
.setLicenseUri(videoResource.getLaUrl())
.setLicenseRequestHeaders(
mapOf(videoResource.getAuthHeaderKey() to videoResource.getAuthHeaderValue())
)
.setMultiSession(true)
.setPlayClearContentWithoutKey(true)
.build()
The error led to interruptions in playback for many users. It happened when switching from Widevine-encrypted video content to clear ads. However, this error doesn't increase on Android phones. The differing behavior between Android phones and TVs suggests a potential hardware-related issue. I've observed a previous issue that might be related to the problem I'm experiencing now. The previous solution involved sleeping for 50ms when creating a decoder fails and then attempting to create it again.
I have a few ideas for addressing this issue, and I'd like to hear your thoughts:
- Increase the sleep duration and make it a user-configurable parameter.
- After a decoder initialization failure, attempt initialization multiple times, with the number of retries being a user-configurable parameter.
If these approaches are viable, I can submit a pull request (PR) to implement these changes. Also, would you happen to have a better solution in mind?
Devices that reproduce the issue
Not a device specific issue: SmartTV 4K, Hisense Philips 4K A1 Smart TV, TCL
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
This issue is not 100% reproducible, but It should be reproduceable with the demo app. I will try to reproduce it in the demo app.
Expected result
No PlaybackException with decoder init failed when switching from WideoVide video content to clear ad.
Actual result
Some times there is an PlaybackException with decoder init failed when switching from WideoVide video content to clear ad.
Media
Any WideVine media stream
{
"name": "HD (cenc)",
"uri": "https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd",
"drm_scheme": "widevine",
"drm_license_uri": "https://proxy.uat.widevine.com/proxy?video_id=2015_tears&provider=widevine_test"
}
Bug Report
- [ ] You will email the zip file produced by
adb bugreport
to [email protected] after filing this issue.
Assigning to @icbaker to get his expertise regarding protected/clear content playback. Looks to me that the API use above is correct, but ibaker has more experience to tell.
I have a few ideas for addressing this issue, and I'd like to hear your thoughts:
- Increase the sleep duration and make it a user-configurable parameter.
- After a decoder initialization failure, attempt initialization multiple times, with the number of retries being a user-configurable parameter.
Have you tried to make these changes locally to confirm that they resolve the issue in your repro case?
It happened when switching from Widevine-encrypted video content to clear ads.
Have you tried using a secure decoder for the clear ads as well (to try and avoid switching decoders): https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setForceSessionsForAudioAndVideoTracks(boolean)
We don't have access to the devices you've reported reproduce the issue. Please can you take an adb bugreport
after reproducing the issue in the demo app and send it to [email protected] with subject Issue #936
? Please update this issue to let us know you've done this.
Have you tried using a secure decoder for the clear ads as well (to try and avoid switching decoders):
I tried setForceSessionsForAudioAndVideoTracks
locally, but that doesn't guarantee no switching decoders, I still see many times decoder switching from AnalyticsListener.onVideoInputFormatChanged()
the decoderReuseEvaluation discardReasons are DISCARD_REASON_MAX_INPUT_SIZE_EXCEEDED
, DISCARD_REASON_VIDEO_COLOR_INFO_CHANGED
.
Have you tried to make these changes locally to confirm that they resolve the issue in your repro case?
Not yet, I'm trying to repro this issue locally, will try to make these changes, and send the adb bugreport
once I find stable repro steps.
Hi @Hiwensen @marcbaechinger any update for this bug to solved. actually I'm also face same issue on Android TV Hisense , can't play video with drm - widevine. let me know if any update here
does anyone have update to solve this issue @all . Error log.
05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: Playback error 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: androidx.media3.exoplayer.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(0, null, null, video/avc, avc1.42C028, 4540800, null, [1920, 1080, -1.0, null], [-1, -1]), format_supported=YES 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:601) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at android.os.Handler.dispatchMessage(Handler.java:102) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at android.os.Looper.loop(Looper.java:223) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at android.os.HandlerThread.run(HandlerThread.java:67) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: Caused by: androidx.media3.exoplayer.video.MediaCodecVideoDecoderException: Decoder failed: OMX.MS.AVC.Decoder 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.createDecoderException(MediaCodecVideoRenderer.java:1862) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:837) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.render(MediaCodecVideoRenderer.java:852) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1047) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:522) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: ... 3 more 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: Caused by: java.lang.IllegalStateException 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:3452) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.mediacodec.SynchronousMediaCodecAdapter.dequeueOutputBufferIndex(SynchronousMediaCodecAdapter.java:108) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1865) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:816) 05-06 18:22:53.520 32330 3007 E ExoPlayerImplInternal: ... 6 more 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: Disable failed. 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: java.lang.IllegalStateException 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at android.media.MediaCodec.native_flush(Native Method) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at android.media.MediaCodec.flush(MediaCodec.java:2298) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.mediacodec.SynchronousMediaCodecAdapter.flush(SynchronousMediaCodecAdapter.java:168) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.flushCodec(MediaCodecRenderer.java:901) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.flushOrReleaseCodec(MediaCodecRenderer.java:894) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onDisabled(MediaCodecRenderer.java:733) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onDisabled(MediaCodecVideoRenderer.java:634) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.BaseRenderer.disable(BaseRenderer.java:197) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.ExoPlayerImplInternal.disableRenderer(ExoPlayerImplInternal.java:1721) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.ExoPlayerImplInternal.resetInternal(ExoPlayerImplInternal.java:1453) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.ExoPlayerImplInternal.stopInternal(ExoPlayerImplInternal.java:1413) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:634) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at android.os.Handler.dispatchMessage(Handler.java:102) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at android.os.Looper.loop(Looper.java:223) 05-06 18:22:53.521 32330 3007 E ExoPlayerImplInternal: at android.os.HandlerThread.run(HandlerThread.java:67) 05-06 18:22:54.166 32330 2968 I ACodec : [OMX.MS.AVC.Decoder] forcing the release of codec
Hi @Hiwensen @marcbaechinger any update for this bug to solved. actually I'm also face same issue on Android TV Hisense , can't play video with drm - widevine. let me know if any update here
@ChetanPatelPlayBoxTV Sorry for the late reply, we developed a solution by creating a custom MediaCodecFactory and RenderersFactory to override MediaCodec.createAdapter() and extend the sleep duration when a MediaCodec instance fails during the creation process. This approach significantly reduced the number of decoder init failed errors. As described in this blog. Do you still have this problem now, can't play any widevine DRM content on your TV?