androidx.media3.exoplayer.ExoPlaybackException: MediaCodecVideoRenderer error
Asked Answered
E

2

5

Video codec error

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)

 

I was using exoplayer for a video url to be playing, it is like instagram reels, so i am coming up with this error , that leads to not to began the play of video after some videos get plyaed, like after 5-6 videos, i was encoutering this issue , that leads to freeze of device , i had to kill the app to let it work again.

Eclat answered 28/7, 2023 at 5:46 Comment(2)
Have you put your ExoPlayer into RecyclerView items? Please provide more info about how you implemented your code. @prabhat biswalSerotine
i am also facing this issue when scrolling 5 or 6 video I am getting this error I am loading webm file from server but after scrolling few video from viewpager error occurs with same reason any work around on this?Naphtha
N
8

Maybe you can try to call setEnableDecoderFallback(true) while creating the ExoPlayer object, it will try to find the available media codec from all the available codec lists. If you don't call setEnableDecoderFallback(true), the enableDecoderFallback is false, it will only use the first available codec and fails to init in some devices.

val exoPlayer = ExoPlayer.Builder(this) .setRenderersFactory(DefaultRenderersFactory(this).setEnableDecoderFallback(true)).build()

Reference - https://github.com/google/ExoPlayer/issues/8987#issuecomment-1311420021

Nonrepresentational answered 18/9, 2023 at 13:4 Comment(4)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Isaiasisak
This solution worked for me. However, it should be noted that there may be a slight hit to performance optimisation using a less efficient or slower decoder.Ambi
Currently it is marked as an unstable API and we need to annotate it as @OptIn(markerClass = UnstableApi.class). For the time being, it works (that's why I upvoted it), but please let us know if you find a more stable solution.Nikko
it works but can you please explain how adding this single line of code works?Naphtha
E
1

If hardware decoder has failed you can try software decoder

Anil beesetti has created awesome videoplayer App for Android, here is [Github][1] link https://github.com/anilbeesetti/nextplayer where he's used his own ffmpeg software decoder Nextlib https://github.com/anilbeesetti/nextlib.

Make sure you have already included Jitpack.io in Settings.gradle

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {
            setUrl("https://jitpack.io")
        }
    }
}

now Go to Build.module add this dependency

dependencies {
implementation "com.github.anilbeesetti.nextlib:nextlib-media3ext:0.6.0"
}

now sync project and in your Playeractivity.java oncreate method paste this code you can also check his android source code in Github https://github.com/anilbeesetti/nextplayer

trackSelector = new DefaultTrackSelector(this);

  int decoder = DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER;
RenderersFactory renderersFactory = new NextRenderersFactory(this).setEnableDecoderFallback(true).setExtensionRendererMode(decoder);
audioAttributes = new AudioAttributes.Builder().setUsage(C.USAGE_MEDIA).setContentType(C.AUDIO_CONTENT_TYPE_MOVIE).build();
player = new ExoPlayer.Builder(this, renderersFactory)
        .setTrackSelector(trackSelector)
        .setAudioAttributes(audioAttributes,true)
        .setHandleAudioBecomingNoisy(true)
        .build();
playerView.setPlayer(player);
playerView.setKeepScreenOn(true);

    MediaItem mediaItem = MediaItem.fromUri(video_stream_Url);
    player.addMediaItem(mediaItem);
    player.prepare();
    player.play();

** Stackoverflow has limited me from Answering any new Question please UpVote this so I can answer more

Enkindle answered 12/12, 2023 at 14:33 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.