androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.73k stars 413 forks source link

Video is not playing and giving error in the logcat - Video codec error android.media.MediaCodec$CodecException: Error 0x80000000 #1280

Open mallikarjunpatelsh opened 7 months ago

mallikarjunpatelsh commented 7 months ago

Version

Media3 main branch

More version details

No response

Devices that reproduce the issue

facing this on Realme Narzo and Opposite

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

No

Reproduction steps

On selecting the video to play, Video is opened and starts loading and loader is shown and after sometime the control is coming to onPlayerError()

Expected result

Video should play

Actual result

Video is not playing instead getting error in logical and the error is

Video codec error
                                                                                                      android.media.MediaCodec$CodecException: Error 0x80000000
2024-04-15 17:55:05.161 22910-24355 ExoPlayerImplInternal   com.wise.devikapluspoint             E  Playback error
                                                                                                      androidx.media3.exoplayer.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(0, null, null, video/avc, avc1.640033, -1, null, [2208, 2196, -1.0, ColorInfo(BT601, Limited range, SDR SMPTE 170M, false, 8bit Luma, 8bit Chroma)], [-1, -1]), format_supported=YES
                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:623)
                                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                                          at android.os.Looper.loopOnce(Looper.java:240)
                                                                                                          at android.os.Looper.loop(Looper.java:351)
                                                                                                          at android.os.HandlerThread.run(HandlerThread.java:67)
                                                                                                      Caused by: androidx.media3.exoplayer.video.MediaCodecVideoDecoderException: Decoder failed: c2.mtk.avc.decoder
                                                                                                          at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.createDecoderException(MediaCodecVideoRenderer.java:1915)
                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:848)
                                                                                                          at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.render(MediaCodecVideoRenderer.java:940)
                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1112)
                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:544)
                                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                                          at android.os.Looper.loopOnce(Looper.java:240) 
                                                                                                          at android.os.Looper.loop(Looper.java:351) 
                                                                                                          at android.os.HandlerThread.run(HandlerThread.java:67) 
                                                                                                      Caused by: android.media.MediaCodec$CodecException: Error 0x80000000
2024-04-15 17:55:05.175 22910-24355 ExoPlayerImplInternal   com.wise.devikapluspoint             E  Disable failed.
                                                                                                      java.lang.IllegalStateException
                                                                                                          at android.media.MediaCodec.native_flush(Native Method)
                                                                                                          at android.media.MediaCodec.flush(MediaCodec.java:2388)
                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter.flush(AsynchronousMediaCodecAdapter.java:248)
                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.flushCodec(MediaCodecRenderer.java:912)
                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.flushOrReleaseCodec(MediaCodecRenderer.java:905)
                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onDisabled(MediaCodecRenderer.java:744)
                                                                                                          at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onDisabled(MediaCodecVideoRenderer.java:711)
                                                                                                          at androidx.media3.exoplayer.BaseRenderer.disable(BaseRenderer.java:220)
                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.disableRenderer(ExoPlayerImplInternal.java:1803)
                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.resetInternal(ExoPlayerImplInternal.java:1525)
                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.stopInternal(ExoPlayerImplInternal.java:1482)
                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:667)
                                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                                          at android.os.Looper.loopOnce(Looper.java:240)
                                                                                                          at android.os.Looper.loop(Looper.java:351)
                                                                                                          at android.os.HandlerThread.run(HandlerThread.java:67)

Media

Not applicable

Bug Report

microkatz commented 7 months ago

Hello @mallikarjunpatelsh,

Thank you for reporting your issue! I see that in your report that you don't hit this issue if you play with the ExoPlayer demo app. I would just like to confirm if that is true?

mallikarjunpatelsh commented 7 months ago

No @microkatz . These videos are not playing at demo app too.

microkatz commented 7 months ago

@mallikarjunpatelsh

If you could attach or email the full bug report then that would be helpful. If you're unable to share [bug reports (https://developer.android.com/studio/debug/bug-report) publicly, please send them to android-media-github@google.com with the subject Issue #1280. Please also update this issue to indicate you've done this.

However, based on the small log snippet, it appears to be a decoder specific issue. I believe that the c2.mtk.avc.decoder is a hardware decoder. What may help is to implement a workaround to use a software decoder instead. Your choice as far as whether to restrict when playing certain content or just not use the c2.mtk.avc.decoder at all.

An app can implement a workaround to remove the c2.mtk.avc.decoder as follows (bottom-up):

The app should override MediaCodecVideoRenderer.getDecoderInfos() roughly as follows:

protected List<MediaCodecInfo> getDecoderInfos(
      MediaCodecSelector mediaCodecSelector, Format format, boolean requiresSecureDecoder)
      throws DecoderQueryException {
    List<MediaCodecInfo> decoderInfos = super.getDecoderInfos(mediaCodecSelector, format, requiresSecureDecoder);
    if (format.sampleMimeType.equals(MimeTypes.VIDEO_H264) 
        && want_to_disable_mtk_hardware_decoder) {
        // check if decoderInfos contains an avc decoder with name equal to c2.mtk.avc.decoder
        // if yes, return a copy of the decoderInfos list excluding that decoder
  }

The app can inject the custom renderer by overriding DefaultRenderersFactory.buildVideoRenderers() The player should be created with the custom DefaultRenderersFactory. which can be passed either on the ExoPlayer.Builder constructor, or with ExoPlayer.Builder.setRenderersFactory.

ThomasKNR commented 6 months ago

Hi, @microkatz , this same problem also happened to me. I've send the bugreport in email just in case OP will not send bugreport. I tried your suggestion, removal of the HW decoder fixed it. However SW renderer will increase load on the device.

baiqindotfubotv commented 1 month ago

I run into this issue on my pixel 2 XL quite often. I have seen this on my firetv 4k device and an android tv running amlogic as well, but much less often. Below is an error log on my Pixel 2 XL playing a widevine h264 content in media3 demo app. I just recharged my Pixel 2 XL it lost battery completely. After powering on, I figured out no video playback works, I checked Hulu+, Display+, ESPN+ etc, as long as it is secure content it won't play. Basically hevc-secure, avc-secure and vp9-secure decoders all stopped working for some reason. Non secure decoders are still working. Reinstalling these apps won't help. The only way to solve it is restarting the device. I don't think this is really media3 related because when this started happening I haven't opened media3 demo app at all. Just posting here FYI.

16:58:53.745  E  Error reading from /proc/net/xt_qtaguid/stats. Please check if this file exists.
16:58:54.788  E  Error reading from /proc/net/xt_qtaguid/stats. Please check if this file exists.
16:58:55.383  E  Predicate 5980654721335871649 dropping data for dimension key (10)0x2010101->11488[I] (10)0x30000->*launch*[S] 
16:58:55.651  E  Predicate 5980654721335871649 dropping data for dimension key (10)0x2010101->11488[I] (10)0x30000->*launch*[S] 
16:58:55.658  E  SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
16:58:55.658  E  SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
16:58:55.796  E  Error reading from /proc/net/xt_qtaguid/stats. Please check if this file exists.
16:58:56.749  E  Receive Passed == base = 13, unit = 1, operation = 2, result = 0
16:58:56.750  E  Daemon: Time-services: Waiting to acceptconnection
16:58:56.752  E  Daemon: Time-services: Waiting to acceptconnection
16:58:56.755  E  Warning: OEMCrypto_ION_Malloc: ION memory has been allocated. g_allocated_mem_size = 3145728
16:58:56.756  E  hlos api version =  15
16:58:56.756  E  tz api version =  15
16:58:56.756  E  OEMCrypto_APIVersion: ends! returns version 15
16:58:56.757  E  hlos api version =  15
16:58:56.757  E  tz api version =  15
16:58:56.757  E  OEMCrypto_APIVersion: ends! returns version 15
16:58:56.781  E  hlos api version =  15
16:58:56.781  E  tz api version =  15
16:58:56.781  E  OEMCrypto_APIVersion: ends! returns version 15
16:58:56.791  E  hlos api version =  15
16:58:56.791  E  tz api version =  15
16:58:56.791  E  OEMCrypto_APIVersion: ends! returns version 15
16:58:56.799  E  Error reading from /proc/net/xt_qtaguid/stats. Please check if this file exists.
16:58:56.811  E  Error: input length 0 is less than 32.
16:58:56.821  E  hlos api version =  15
16:58:56.821  E  tz api version =  15
16:58:56.821  E  OEMCrypto_APIVersion: ends! returns version 15
16:58:56.851  E  hlos api version =  15
16:58:56.851  E  tz api version =  15
16:58:56.851  E  OEMCrypto_APIVersion: ends! returns version 15
16:58:56.854  E  hlos api version =  15
16:58:56.854  E  tz api version =  15
16:58:56.854  E  OEMCrypto_APIVersion: ends! returns version 15
16:58:56.855  E  hlos api version =  15
16:58:56.855  E  tz api version =  15
16:58:56.855  E  OEMCrypto_APIVersion: ends! returns version 15
16:58:57.097  E  grantorIdx must be less than 3
16:58:57.097  E  grantorIdx must be less than 3
16:58:57.101  E  grantorIdx must be less than 3
16:58:57.101  E  grantorIdx must be less than 3
16:58:57.103  E  Error: OEMCrypto_CopyBuffer_V14 ION has not been allocated!
16:58:57.103  E  Error: OEMCrypto_CopyBuffer_V14 failed and return = 80002
16:58:57.103  E  [crypto_session.cpp(1521):Decrypt] OEMCrypto_DecryptCENC failed: status = 80002
16:58:57.103  E  Decrypt error in session sid114 during a sample without protected data: 1
16:58:57.104  E  queueCSDInputBuffer failed w/ error -2147483648
16:58:57.109  E  Audio codec error
                   android.media.MediaCodec$CodecException: Error 0x80000000
                       at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
                       at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:3452)
                       at androidx.media3.exoplayer.mediacodec.SynchronousMediaCodecAdapter.dequeueOutputBufferIndex(SynchronousMediaCodecAdapter.java:108)
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1994)
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:873)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1136)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:561)
                       at android.os.Handler.dispatchMessage(Handler.java:102)
                       at android.os.Looper.loop(Looper.java:223)
                       at android.os.HandlerThread.run(HandlerThread.java:67)
16:58:57.123  E  Playback error
                   androidx.media3.exoplayer.ExoPlaybackException: MediaCodecAudioRenderer error, index=1, format=Format(0, null, null, audio/mp4a-latm, mp4a.40.2, 130900, en, [-1, -1, -1.0, null], [2, 44100]), format_supported=YES
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:640)
                       at android.os.Handler.dispatchMessage(Handler.java:102)
                       at android.os.Looper.loop(Looper.java:223)
                       at android.os.HandlerThread.run(HandlerThread.java:67)
                   Caused by: androidx.media3.exoplayer.mediacodec.MediaCodecDecoderException: Decoder failed: c2.android.aac.decoder
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.createDecoderException(MediaCodecRenderer.java:1024)
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:893)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1136)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:561)
                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                       at android.os.Looper.loop(Looper.java:223) 
                       at android.os.HandlerThread.run(HandlerThread.java:67) 
                   Caused by: android.media.MediaCodec$CodecException: Error 0x80000000
                       at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
                       at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:3452)
                       at androidx.media3.exoplayer.mediacodec.SynchronousMediaCodecAdapter.dequeueOutputBufferIndex(SynchronousMediaCodecAdapter.java:108)
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1994)
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:873)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1136) 
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:561) 
                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                       at android.os.Looper.loop(Looper.java:223) 
                       at android.os.HandlerThread.run(HandlerThread.java:67) 
16:58:57.129  E  Disable failed.
                   android.media.MediaCodec$CodecException: Error 0x80000000
                       at android.media.MediaCodec.native_flush(Native Method)
                       at android.media.MediaCodec.flush(MediaCodec.java:2298)
                       at androidx.media3.exoplayer.mediacodec.SynchronousMediaCodecAdapter.flush(SynchronousMediaCodecAdapter.java:168)
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.flushCodec(MediaCodecRenderer.java:960)
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.flushOrReleaseCodec(MediaCodecRenderer.java:953)
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onDisabled(MediaCodecRenderer.java:780)
                       at androidx.media3.exoplayer.audio.MediaCodecAudioRenderer.onDisabled(MediaCodecAudioRenderer.java:670)
                       at androidx.media3.exoplayer.BaseRenderer.disable(BaseRenderer.java:220)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.disableRenderer(ExoPlayerImplInternal.java:1846)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.resetInternal(ExoPlayerImplInternal.java:1566)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.stopInternal(ExoPlayerImplInternal.java:1523)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:686)
                       at android.os.Handler.dispatchMessage(Handler.java:102)
                       at android.os.Looper.loop(Looper.java:223)
                       at android.os.HandlerThread.run(HandlerThread.java:67)
16:58:57.135  E  Reset failed.
                   android.media.MediaCodec$CodecException: Error 0x80000000
                       at android.media.MediaCodec.native_stop(Native Method)
                       at android.media.MediaCodec.stop(MediaCodec.java:2251)
                       at androidx.media3.exoplayer.mediacodec.SynchronousMediaCodecAdapter.release(SynchronousMediaCodecAdapter.java:181)
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.releaseCodec(MediaCodecRenderer.java:805)
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onReset(MediaCodecRenderer.java:787)
                       at androidx.media3.exoplayer.audio.MediaCodecAudioRenderer.onReset(MediaCodecAudioRenderer.java:681)
                       at androidx.media3.exoplayer.BaseRenderer.reset(BaseRenderer.java:227)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.resetInternal(ExoPlayerImplInternal.java:1576)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.stopInternal(ExoPlayerImplInternal.java:1523)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:686)
                       at android.os.Handler.dispatchMessage(Handler.java:102)
                       at android.os.Looper.loop(Looper.java:223)
                       at android.os.HandlerThread.run(HandlerThread.java:67)
16:58:57.151  E  playerFailed [eventTime=1.57, mediaPos=0.00, window=0, period=0, errorCode=ERROR_CODE_DECODING_FAILED
                   androidx.media3.exoplayer.ExoPlaybackException: MediaCodecAudioRenderer error, index=1, format=Format(0, null, null, audio/mp4a-latm, mp4a.40.2, 130900, en, [-1, -1, -1.0, null], [2, 44100]), format_supported=YES
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:640)
                       at android.os.Handler.dispatchMessage(Handler.java:102)
                       at android.os.Looper.loop(Looper.java:223)
                       at android.os.HandlerThread.run(HandlerThread.java:67)
                   Caused by: androidx.media3.exoplayer.mediacodec.MediaCodecDecoderException: Decoder failed: c2.android.aac.decoder
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.createDecoderException(MediaCodecRenderer.java:1024)
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:893)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1136)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:561)
                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                       at android.os.Looper.loop(Looper.java:223) 
                       at android.os.HandlerThread.run(HandlerThread.java:67) 
                   Caused by: android.media.MediaCodec$CodecException: Error 0x80000000
                       at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
                       at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:3452)
                       at androidx.media3.exoplayer.mediacodec.SynchronousMediaCodecAdapter.dequeueOutputBufferIndex(SynchronousMediaCodecAdapter.java:108)
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1994)
                       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:873)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1136) 
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:561) 
                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                       at android.os.Looper.loop(Looper.java:223) 
                       at android.os.HandlerThread.run(HandlerThread.java:67) 
                 ]