视频编解码器错误
androidx.media3.exoplayer.mediacodec.MediaCodecRenderer$DecoderInitializationException:
Decoder init failed: OMX.Exynos.avc.dec, Format(2, null, null, video/avc, avc1.640033, -1, null, [540, 960, 13.037374], [-1, -1])
at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1015)
at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:539)
at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1447)
at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:920)
at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:948)
at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:763)
at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1015)
at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:510)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: android.media.MediaCodec$CodecException: Failed to initialize OMX.Exynos.avc.dec, error 0xfffffff4 (NO_MEMORY)
at android.media.MediaCodec.native_setup(Native Method)
at android.media.MediaCodec.<init>(MediaCodec.java:1999)
at android.media.MediaCodec.<init>(MediaCodec.java:1977)
at android.media.MediaCodec.createByCodecName(MediaCodec.java:1947)
at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter$Factory.createAdapter(AsynchronousMediaCodecAdapter.java:95)
at androidx.media3.exoplayer.mediacodec.DefaultMediaCodecAdapterFactory.createAdapter(DefaultMediaCodecAdapterFactory.java:113)
at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1093)
at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1004)
at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:539)
at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1447)
at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:920)
at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:948)
at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:763)
at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1015)
at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:510)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.os.HandlerThread.run(HandlerThread.java:67)
我使用 exoplayer 来播放视频网址,它就像 Instagram 卷轴,所以我遇到了这个错误,这导致在某些视频播放后(例如 5-6 个视频后)无法开始播放视频,我遇到了这个问题,这导致设备冻结,我不得不杀死该应用程序才能让它再次工作。
也许您可以尝试在创建 ExoPlayer 对象时调用 setEnableDecoderFallback(true) ,它会尝试从所有可用的编解码器列表中查找可用的媒体编解码器。如果不调用 setEnableDecoderFallback(true),enableDecoderFallback 为 false,它只会使用第一个可用的编解码器,并且在某些设备上无法初始化。
val exoPlayer = ExoPlayer.Builder(this) .setRenderersFactory(DefaultRenderersFactory(this).setEnableDecoderFallback(true)).build()
参考 - https://github.com/google/ExoPlayer/issues/8987#issuecomment-1311420021