com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed:
See original GitHub issue Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.Exynos.avc.dec, Format(1, null, null, video/avc, avc1.4D402A, -1, null, [1920, 1080, 60.000004], [-1, -1])
Every Time generate this issue
- Play video in our app -> works fine
- Run other video application
- Start video in other video application
- Minimize other video application
- Go back to our app
- Try to play video -> fail DecoderInitializationException
- Kill other video application
- Go back to our app
- Try to play video -> works fine
And Also show black screen on playerview
2021-07-27 16:51:10.097 10029-10904/com.oneintro.intromaker E/ExoPlayerImplInternal: Playback error
com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.4D402A, -1, null, [1920, 1080, 60.000004], [-1, -1]), format_supported=YES
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:555)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.Exynos.avc.dec, Format(1, null, null, video/avc, avc1.4D402A, -1, null, [1920, 1080, 60.000004], [-1, -1])
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1051)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:606)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1465)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:713)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:998)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:830)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:945)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: android.media.MediaCodec$CodecException: Error 0xffffec77
at android.media.MediaCodec.native_configure(Native Method)
at android.media.MediaCodec.configure(MediaCodec.java:1943)
at android.media.MediaCodec.configure(MediaCodec.java:1872)
at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter$Factory.createAdapter(SynchronousMediaCodecAdapter.java:50)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1137)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1044)
Is there any way to release programmatically codec resources which are used by another app? This is quite a significant problem for us.
I can not find any solution so if you have any solution please help me out.
I have wasted 3 days in this issue but have not yet found a solution. Please give solution.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:27 (8 by maintainers)
Top Results From Across the Web
java - Video codec error com.google.android.exoplayer2 ...
Video codec error com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: Android ...
Read more >Class MediaCodecRenderer.DecoderInitializationException
com.google.android.exoplayer2.mediacodec.MediaCodecRenderer. ... The MediaCodecInfo of the decoder that failed to initialize. String, diagnosticInfo.
Read more >ExoPlayer Error - Google Groups
com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.
Read more >MediaCodecRenderer (library API) - javadoc.io
An abstract renderer that uses MediaCodec to decode samples for rendering. ... Fields inherited from interface com.google.android.exoplayer2.
Read more >com.google.android.exoplayer2.mediacodec ... - Tabnine
public DecoderInitializationException(Format format, Throwable cause, boolean secureDecoderRequired, String decoderName) { this( "Decoder init failed: " + ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The player will raise an error on the
AnalyticsListener.onPlayerError
callback and the passedExoPlaybackException
will contain aMediaCodecRenderer.DecoderInitializationException
. You can see that in the first stack trace you posted on the issue description. In your app, you should add anAnalyticsListener
to the player and ifonPlayerError
is raised, you can inspect if it was the decoder that failed as follows:I’ve added some extra statements to show you some of the information you can obtain the exception’s MediaCodecInfo, such as the MIME type (from which you can tell if it’s an H264 decoder), the specific decoder name and if it’s a hardware one.
Unfortunately, if you wait until the player fails and then try out with a different decoder, your app will need extra time until it starts playing the video. Please try if
DefaultRenderersFactory. setEnableDecoderFallback(true)
solves your problem before you try this solution.By default, the DefaultRenderersFactory will prefer a hardware decoder if one exists. This comes down to the device capabilities, and the player will query the device to find out what decoders are available for the specific video. If for a certain video format there is a hardware and a software decoder, the player’s default behavior is to prefer to hardware. But if the device only has one decoder for a certain video format, the player will pick that decoder nevertheless.
This checks is the video format is H264. Media formats are defined by a MIME type. You can check the player’s MimeTypes class. For the snippet of code I shared above, this condition changes the default codec selection only for H264 (you’d want the default behavior for other codecs). Feel free to change the condition if you find more issues with decoders not being available.
This is a setting used by the demo app, and works if you want to use the DefaultRenderersFactory with ExoPlayer extensions (feel free to ignore if you don’t use extensions).
Please let me know if I can assist further, otherwise I will close tis issue now.
I can think of two options
MediaCodecSelector
to the player which will have your custom logic to select an H264 decoder (if the video format is H264, you have to pick an H264 decoder). On an Android platform, you typically find a hardware and software decoder for H264. By default, ExoPlayer usesMediaCodecSelector.DEFAULT
which prefers the hardware decoder. You may create a customMediaCodecSelector
that returns a list of decoders, with the software decoder for H264 on the top of the list instead of the hardware decoder. An easy way to achieve that is to wrapMediaCodecSelector.DEFAULT
and re-order its returned results. For example, in the demo app, you can do something like thisPlease note the following for option 3:
Overall, I believe the issue you are seeing so far is not with ExoPlayer but with the video editing apps that seem to not release their resources when put them in the background. I have not managed to reproduce using Pixel devices and a Samsung S9. My guess is that the specific devices you are testing (Samsung J5/J7) may not have the ability to share resources. That said, I am not sure how else we have help you with the issue you are facing.