TheWidlarzGroup / react-native-video

A <Video /> component for react-native
https://thewidlarzgroup.github.io/react-native-video/
MIT License
7.17k stars 2.89k forks source link

The video stays black and selecting an audio track or video track causes an error. #3022

Closed Arekjaar4 closed 1 month ago

Arekjaar4 commented 1 year ago

Bug

Platform

Which player are you experiencing the problem on: Android

Environment info

React native info output:

 System:
    OS: Windows 10 10.0.22000
    CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
    Memory: 3.20 GB / 15.89 GB
  Binaries:
    Node: 14.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 7.24.1 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK:
      Android NDK: 21.3.6528147
    Windows SDK: Not Found
  IDEs:
    Android Studio: Version  4.2.0.0 AI-202.7660.26.42.7351085
    Visual Studio: Not Found
  Languages:
    Java: 1.8.0_261
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.0.0 => 18.0.0
    react-native: 0.69.6 => 0.69.6
    react-native-windows: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
info React Native v0.71.1 is now available (your project is running on v0.69.6)

Library version: "react-native-video": "^6.0.0-alpha.3"

Steps To Reproduce

These three videos cause me problems when playing them with react-native-video. The links I attach only last 12 hours due to their content.

  1. http://umetop.ottc.pro/series/CPR14KRJTP/74W5QAQEZH/462683.mkv
  2. http://umetop.ottc.pro/series/CPR14KRJTP/74W5QAQEZH/258331.mkv
  3. http://umetop.ottc.pro/movie/CPR14KRJTP/74W5QAQEZH/488270.mkv

The one and two are visible but not audible, and selecting an audio track causes the following error:

{ "error": Object { "errorCode": "24001", "errorException": "com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/x-unknown, null, -1, und, [720, 304, -1.0], [-1, -1]), format_supported=NO_UNSUPPORTED_TYPE", "errorStackTrace": "com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/x-unknown, null, -1, und, [720, 304, -1.0], [-1, -1]), format_supported=NO_UNSUPPORTED_TYPE at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:566) at android.os.Handler.dispatchMessage(Handler.java:108) at android.os.Looper.loop(Looper.java:216) at android.os.HandlerThread.run(HandlerThread.java:65) Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: [-49999], Format(1, null, null, video/x-unknown, null, -1, und, [720, 304, -1.0], [-1, -1]) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:996) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:546) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1450) at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:877) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:963) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:779) at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:989) at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:490) ... 3 more ", "errorString": "ExoPlaybackException: ERROR_CODE_DECODER_INIT_FAILED", }, }

The 3 is heard but not seen and when you select a video track, the following error occurs:

{ "error": Object { "errorCode": "24001", "errorException": "com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/x-unknown, null, -1, und, [720, 304, -1.0], [-1, -1]), format_supported=NO_UNSUPPORTED_TYPE", "errorStackTrace": "com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/x-unknown, null, -1, und, [720, 304, -1.0], [-1, -1]), format_supported=NO_UNSUPPORTED_TYPE at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:566) at android.os.Handler.dispatchMessage(Handler.java:108) at android.os.Looper.loop(Looper.java:216) at android.os.HandlerThread.run(HandlerThread.java:65) Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: [-49999], Format(1, null, null, video/x-unknown, null, -1, und, [720, 304, -1.0], [-1, -1]) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:996) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:546) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1450) at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:877) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:963) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:779) at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:989) at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:490) ... 3 more ", "errorString": "ExoPlaybackException: ERROR_CODE_DECODER_INIT_FAILED", }, }

Reproducible sample code

<Video
        key={keyload + 'vidroplayer'}
        /*bufferConfig={{
          minBufferMs: 15000, //number
          maxBufferMs: 100000, //number
          bufferForPlaybackMs: 2500, //number
          bufferForPlaybackAfterRebufferMs: 5000 //number
        }}*/
        ref={(ref) => {setVideo(ref)}}
        style={styles.video}
        onLoad={(data) => load(data)}//
        onLoadStart={(info) => loadStart(info)}
        source={{
          uri: uriLoad, /*initOptions: ['--codec=avcodec']*/
          initOptions: [
            '--no-audio',
            '--rtsp-tcp',
            '--network-caching=150',
            '--rtsp-caching=150',
            '--no-stats',
            '--tcp-caching=150',
            '--realrtsp-caching=150',
          ]
        }}
        controls={false}
        fullscreen={true}
        paused={paused}
        volume={volumen}
        fullscreenAutorotate={true}
        selectedVideoTrack={videoTrack.value !== '' ? videoTrack : {}}//videoTrack.value !== '' ? videoTrack : {}
        selectedAudioTrack={audioTrack?.value !== '' ? audioTrack : {}}//audioTrack?.value !== '' ? audioTrack : {}
        selectedTextTrack={textTrack}
        resizeMode={resizemode}
        onEnd={() => end()}
        isLooping 
        onError={error => playerError(error)}
        onPlaybackStatusUpdat
        allowsExternalPlayback
        e={status => setStatus(() => status)}//setStatus(() => status)
    />
ankit-gl commented 1 year ago

Facing Same issue error.errorCode: 24003 error.errorException : com.google.android.exoplayer2.t: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.4D4029, -1, null, [1920, 1080, 25.0], [-1, -1]), format_supported=YES

Arekjaar4 commented 1 year ago

I have solved it by combining this library with the react-native-vlc-media-player library as indicated in this article https://link.medium.com/CzEIBMG45wb

freeboub commented 1 year ago

It looks like a codec issue... On my side, I fixed similar issue by adding (but not 100% sure it is the same) implementation "com.google.android.exoplayer:extension-ffmpeg:$exoplayerVersion" in RNV build.gradle If it doesn't work, you should try to reproduce the issue with a standalone exoplayer sample...

Arekjaar4 commented 1 year ago

hi @freeboub I have this error: Could not find com.google.android.exoplayer:extension-ffmpeg:2.11.7

what version and repository do you use?

freeboub commented 1 year ago

Please put 2.18.1 for the version

Arekjaar4 commented 1 year ago

@freeboub same error: Could not find com.google.android.exoplayer:extension-ffmpeg:2.18.1

Stoneski93 commented 1 year ago

Same error like Arekjaar4

VladosusCocosus commented 1 year ago

Same, is someone find how to fix it?

vatsalsoni1302 commented 1 year ago

Facing Same issue error.errorCode: 24003 error.errorException : com.google.android.exoplayer2.t: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.4D4029, -1, null, [1920, 1080, 25.0], [-1, -1]), format_supported=YES

same issue any solution

sridhard commented 1 year ago

Facing Same issue error.errorCode: 24003. Any soilution

parthasarathi95 commented 1 year ago

I am facing the issue. I have a vertical video-playing app. Tapping on a video opens a new page where the user can see that video vertically. But sometimes some videos are not playing and show only a black screen. When I log the error it is telling

{"error":{"errorStackTrace":"com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(0, null, null, video/avc, avc1.4D4020, 4077348, null, [608, 1080, 60.0], [-1, -1]), format_supported=YES\n\tat com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:566)\n\tat android.os.Handler.dispatchMessage(Handler.java:102)\n\tat android.os.Looper.loopOnce(Looper.java:233)\n\tat android.os.Looper.loop(Looper.java:344)\n\tat android.os.HandlerThread.run(HandlerThread.java:67)\nCaused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.qcom.video.decoder.avc, Format(0, null, null, video/avc, avc1.4D4020, 4077348, null, [608, 1080, 60.0], [-1, -1])\n\tat com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1030)\n\tat com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:546)\n\tat com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1450)\n\tat com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:877)\n\tat com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:963)\n\tat com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:779)\n\tat com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:989)\n\tat com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:490)\n\t... 4 more\nCaused by: android.media.MediaCodec$CodecException: Failed to initialize OMX.qcom.video.decoder.avc, error 0xfffffff4\n\tat android.media.MediaCodec.native_setup(Native Method)\n\tat android.media.MediaCodec.(MediaCodec.java:1961)\n\tat android.media.MediaCodec.createByCodecName(MediaCodec.java:1938)\n\tat com.google.android.exoplayer2.mediacodec.AsynchronousMediaCodecAdapter$Factory.createAdapter(AsynchronousMediaCodecAdapter.java:95)\n\tat com.google.android.exoplayer2.mediacodec.DefaultMediaCodecAdapterFactory.createAdapter(DefaultMediaCodecAdapterFactory.java:108)\n\tat com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1108)\n\tat com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1019)\n\t... 11 more\n","errorCode":"24001","errorException":"com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(0, null, null, video/avc, avc1.4D4020, 4077348, null, [608, 1080, 60.0], [-1, -1]), format_supported=YES","errorString":"ExoPlaybackException: ERROR_CODE_DECODER_INIT_FAILED"}}

facugu1998 commented 1 year ago

We faced the same problem, and realized that the callback function onAttachedWindow in ReactExoplayerView.java was being called multiple times, and then calling initializePlayer(). In order to fix that, we replaced the callback with:

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    if(player == null){
        initializePlayer();
    }
}

Maybe this is not the best solution, but it worked for us.

lunasky-hy commented 1 year ago

I also faced the same issue. I was able to resolve it by modifying onAttachedToWindow in ReactExpplayerView.java like a the comment mentioned by @facugu1998, and it started working correctly. I believe this fix is both straightforward and critical.

freeboub commented 5 months ago

This issue should be retested with 6.0.0-RC.0 or 6.0.0-RC.2 (coming really soon). can you please check of this is still reproduced ?