[Bug] Hardware Acceleration Decoders (h264_mediacodec) Fail to Load Due to FFmpeg Experimental Codec Refusal on Android Client
Describe the bug Attempting to use the hardware acceleration decoders, h264_v4l2m2m or h264_mediacodec, on an Android 10 client device results in a decoding error and stream failure. The error message suggests a refusal to open an experimental codec. Specifically, when either of these two decoders is selected, the application crashes or fails to start the video stream, displaying the error shown in the second attached image. The first decoder in the list works but exhibits severe screen tearing and fragmentation (choppy/laggy).
To Reproduce
-
Launch the SysDVR client application on the Android device.
-
Navigate to the decoder settings or the decoder selection list.
-
Select either the h264_v4l2m2m or the h264_mediacodec decoder.
-
Attempt to connect and start the video stream from the Switch.
-
The error (shown in the second image) is thrown, and the stream fails to load.
Expected behavior The selected hardware decoders (h264_v4l2m2m and h264_mediacodec) should successfully open and utilize the Android device's hardware acceleration to provide a smooth, tear-free, and stable video stream. Alternatively, if the codec is experimental, the application should pass the necessary flags (like AV_CODEC_FLAG_OPEN_EXPERIMENTAL) to allow it to be loaded, or fallback gracefully.
Setup information
- Os: Android 10
- Console firmware: 20.5.0
- Custom firmware name and version: Atmosphere 1.9.1
- SysDVR version 6.2.1
- SysDVR Android client version 6.2.2
Additional context The issue appears to be related to FFmpeg's handling of "experimental" decoders. FFmpeg, which SysDVR uses for decoding, marks the Android hardware decoder (h264_mediacodec) as experimental.
The underlying cause is likely due to the avcodec_open2 function call in the SysDVR client code not passing any options, causing FFmpeg to reject the experimental codec by default for safety:
// Player.cs around line 202
avcodec_open2(codectx, codec, null).AssertZero("Couldn't open the codec.");
The presence of null as the options argument is preventing the necessary flag (e.g., to enable experimental codecs) from being passed, leading to the reported error.
The flag you mentioned "AV_CODEC_FLAG_OPEN_EXPERIMENTAL" does not return any hits on google, wouldn't be surprised if it's some kind of AI allucination.
I enabled the closes thing that i could find in the docs that is FF_COMPLIANCE_EXPERIMENTAL https://github.com/exelix11/SysDVR/blob/96af3d8a593c86c0764e4a9f5e0e9d15b10becce/Client/Targets/Player/Player.cs#L272-L276
You can get this build to test it, note that it's behind the debug.log flag, you need to enable it manually in the settings first.
When it's enabled you should see Setting strict compliance to experimental for the decoder in the logcat output
Thank you for your effort. I tried the version you provided, but it still throws an error. Maybe the issue is on my side?
➜ ~ adb logcat --pid $(adb shell pidof exelix11.sysdvr)
--------- beginning of main
11-20 12:18:18.224 7238 7238 I Zygote : seccomp disabled by setenforce 0
11-20 12:18:18.234 7238 7238 E exelix11.sysdv: Not starting debugger since process cannot load the jdwp agent.
11-20 12:18:18.323 7238 7238 I SysDVRJava: SysDVRActivity onCreate()
11-20 12:18:18.323 7238 7238 V SDL : Device: mt9638
11-20 12:18:18.323 7238 7238 V SDL : Model: 7T864_A4E
11-20 12:18:18.323 7238 7238 V SDL : onCreate()
11-20 12:18:18.340 7238 7238 V SDL : nativeSetupJNI()
11-20 12:18:18.341 7238 7238 V SDL : AUDIO nativeSetupJNI()
11-20 12:18:18.341 7238 7238 V SDL : CONTROLLER nativeSetupJNI()
11-20 12:18:18.367 7238 7238 I System.out: line=10.00.241126
11-20 12:18:18.367 7238 7238 D theme_framework: getResourceNameFromId=android:drawable/screen_background_selector_dark
11-20 12:18:18.373 7238 7238 I SysDVRJava: SysDVRActivity created
11-20 12:18:18.376 7238 7238 V SDL : onStart()
11-20 12:18:18.377 7238 7238 V SDL : onResume()
11-20 12:18:18.428 7238 7238 V SDL : surfaceCreated()
11-20 12:18:18.428 7238 7238 V SDL : surfaceChanged()
11-20 12:18:18.429 7238 13554 E gralloc : Arm Module v1.0
11-20 12:18:18.433 7238 7238 V SDL : Window size: 1920x1080
11-20 12:18:18.433 7238 7238 V SDL : Device size: 1920x1080
11-20 12:18:18.443 7238 7238 E SensorManager: sensor or listener is null
11-20 12:18:18.443 7238 7238 E SensorManager: sensor or listener is null
11-20 12:18:18.444 7238 13569 V SDL : Running main function SDL_main from library /data/app/exelix11.sysdvr-tE526Xsk6y_a0g5-DE9CUA==/lib/arm/libmain.so
11-20 12:18:18.444 7238 13569 V SDL : nativeRunMain()
11-20 12:18:18.445 7238 13569 E SysDVRLogger: sdl main called()
11-20 12:18:18.447 7238 13569 E SysDVRLogger: Initializing threading
11-20 12:18:18.447 7238 13569 E SysDVRLogger: Calling entrypoint
11-20 12:18:18.458 7238 13554 D mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
11-20 12:18:18.467 7238 13554 W Gralloc3: mapper 3.x is not supported
11-20 12:18:18.472 7238 13554 D gralloc : [mma_open:49]
11-20 12:18:18.479 7238 7238 I SDLThread: type=1400 audit(0.0:36467): avc: denied { read } for name="cpu.cfs_quota_us" dev="cgroup" ino=9 scontext=u:r:untrusted_app:s0:c20,c256,c512,c768 tcontext=u:object_r:cgroup:s0 tclass=file permissive=1
11-20 12:18:18.479 7238 7238 I SDLThread: type=1400 audit(0.0:36468): avc: denied { open } for path="/dev/cpuctl/cpu.cfs_quota_us" dev="cgroup" ino=9 scontext=u:r:untrusted_app:s0:c20,c256,c512,c768 tcontext=u:object_r:cgroup:s0 tclass=file permissive=1
11-20 12:18:18.479 7238 7238 I SDLThread: type=1400 audit(0.0:36469): avc: denied { getattr } for path="/dev/cpuctl/cpu.cfs_quota_us" dev="cgroup" ino=9 scontext=u:r:untrusted_app:s0:c20,c256,c512,c768 tcontext=u:object_r:cgroup:s0 tclass=file permissive=1
11-20 12:18:18.485 7238 7238 V SDL : onWindowFocusChanged(): true
11-20 12:18:18.500 7238 13569 E SysDVRLogger: Nativelogger has been initialized !
11-20 12:18:18.543 7238 13569 E SysDVRLogger: SysDVR-Client 6.2.2 - by exelix
11-20 12:18:18.543 7238 13569 E SysDVRLogger:
11-20 12:18:18.543 7238 13569 E SysDVRLogger: https://github.com/exelix11/SysDVR
11-20 12:18:18.543 7238 13569 E SysDVRLogger:
11-20 12:18:18.543 7238 13569 E SysDVRLogger: Build ID: 96af3d8
11-20 12:18:18.543 7238 13569 E SysDVRLogger:
11-20 12:18:18.551 7238 13569 E SysDVRLogger: Settings loaded
11-20 12:18:18.552 7238 13569 E SysDVRLogger:
11-20 12:18:18.601 7238 13569 E SysDVRLogger: Requested language zh-cn
11-20 12:18:18.601 7238 13569 E SysDVRLogger:
11-20 12:18:18.602 7238 13569 E SysDVRLogger: Loading resource strings/Italian.json
11-20 12:18:18.602 7238 13569 E SysDVRLogger:
11-20 12:18:18.603 7238 13569 E SysDVRLogger: Resource loaded with size 12369
11-20 12:18:18.603 7238 13569 E SysDVRLogger:
11-20 12:18:18.603 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e5cbc000
11-20 12:18:18.603 7238 13569 E SysDVRLogger:
11-20 12:18:18.606 7238 13569 E SysDVRLogger: Loading resource strings/english.json
11-20 12:18:18.606 7238 13569 E SysDVRLogger:
11-20 12:18:18.607 7238 13569 E SysDVRLogger: Resource loaded with size 11808
11-20 12:18:18.607 7238 13569 E SysDVRLogger:
11-20 12:18:18.607 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e5cc1000
11-20 12:18:18.607 7238 13569 E SysDVRLogger:
11-20 12:18:18.607 7238 13569 E SysDVRLogger: Loading resource strings/french.json
11-20 12:18:18.607 7238 13569 E SysDVRLogger:
11-20 12:18:18.608 7238 13569 E SysDVRLogger: Resource loaded with size 13613
11-20 12:18:18.608 7238 13569 E SysDVRLogger:
11-20 12:18:18.608 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e5ce8800
11-20 12:18:18.608 7238 13569 E SysDVRLogger:
11-20 12:18:18.608 7238 13569 E SysDVRLogger: Loading resource strings/german.json
11-20 12:18:18.608 7238 13569 E SysDVRLogger:
11-20 12:18:18.609 7238 13569 E SysDVRLogger: Resource loaded with size 12636
11-20 12:18:18.609 7238 13569 E SysDVRLogger:
11-20 12:18:18.609 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e5cec000
11-20 12:18:18.609 7238 13569 E SysDVRLogger:
11-20 12:18:18.609 7238 13569 E SysDVRLogger: Loading resource strings/polish.json
11-20 12:18:18.609 7238 13569 E SysDVRLogger:
11-20 12:18:18.610 7238 13569 E SysDVRLogger: Resource loaded with size 12412
11-20 12:18:18.610 7238 13569 E SysDVRLogger:
11-20 12:18:18.610 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e5cef800
11-20 12:18:18.610 7238 13569 E SysDVRLogger:
11-20 12:18:18.611 7238 13569 E SysDVRLogger: Loading resource strings/portuguese.json
11-20 12:18:18.611 7238 13569 E SysDVRLogger:
11-20 12:18:18.611 7238 13569 E SysDVRLogger: Resource loaded with size 12328
11-20 12:18:18.611 7238 13569 E SysDVRLogger:
11-20 12:18:18.612 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e5cf3000
11-20 12:18:18.612 7238 13569 E SysDVRLogger:
11-20 12:18:18.612 7238 13569 E SysDVRLogger: Loading resource strings/pt-BR.json
11-20 12:18:18.612 7238 13569 E SysDVRLogger:
11-20 12:18:18.613 7238 13569 E SysDVRLogger: Resource loaded with size 12971
11-20 12:18:18.613 7238 13569 E SysDVRLogger:
11-20 12:18:18.613 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e5cf6800
11-20 12:18:18.613 7238 13569 E SysDVRLogger:
11-20 12:18:18.614 7238 13569 E SysDVRLogger: Loading resource strings/spanish.json
11-20 12:18:18.614 7238 13569 E SysDVRLogger:
11-20 12:18:18.614 7238 13569 E SysDVRLogger: Resource loaded with size 12755
11-20 12:18:18.614 7238 13569 E SysDVRLogger:
11-20 12:18:18.615 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e5cfa000
11-20 12:18:18.615 7238 13569 E SysDVRLogger:
11-20 12:18:18.615 7238 13569 E SysDVRLogger: Loading resource strings/zh-CN.json
11-20 12:18:18.615 7238 13569 E SysDVRLogger:
11-20 12:18:18.615 7238 13569 E SysDVRLogger: Resource loaded with size 10616
11-20 12:18:18.616 7238 13569 E SysDVRLogger:
11-20 12:18:18.616 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e5cc4000
11-20 12:18:18.616 7238 13569 E SysDVRLogger:
11-20 12:18:18.616 7238 13569 E SysDVRLogger: Loading resource strings/zh-TW.json
11-20 12:18:18.616 7238 13569 E SysDVRLogger:
11-20 12:18:18.617 7238 13569 E SysDVRLogger: Resource loaded with size 10872
11-20 12:18:18.617 7238 13569 E SysDVRLogger:
11-20 12:18:18.617 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e5cca000
11-20 12:18:18.617 7238 13569 E SysDVRLogger:
11-20 12:18:18.617 7238 13569 E SysDVRLogger: Loading resource fonts/NotoSansSC-Regular.ttf
11-20 12:18:18.617 7238 13569 E SysDVRLogger:
11-20 12:18:18.857 7238 13569 E SysDVRLogger: Resource loaded with size 10560380
11-20 12:18:18.857 7238 13569 E SysDVRLogger:
11-20 12:18:18.871 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e16d8000
11-20 12:18:18.871 7238 13569 E SysDVRLogger:
11-20 12:18:18.871 7238 13569 E SysDVRLogger: Loading translation strings/zh-CN.json
11-20 12:18:18.871 7238 13569 E SysDVRLogger:
11-20 12:18:18.871 7238 13569 E SysDVRLogger: Loading resource strings/zh-CN.json
11-20 12:18:18.871 7238 13569 E SysDVRLogger:
11-20 12:18:18.872 7238 13569 E SysDVRLogger: Resource loaded with size 10616
11-20 12:18:18.872 7238 13569 E SysDVRLogger:
11-20 12:18:18.872 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e5d11000
11-20 12:18:18.872 7238 13569 E SysDVRLogger:
11-20 12:18:18.876 7238 13569 E SysDVRLogger: Initializing SDL
11-20 12:18:18.876 7238 13569 E SysDVRLogger:
11-20 12:18:18.886 7238 13569 I SDL/APP : Adding input device with name 5
11-20 12:18:18.886 7238 13569 I SDL/APP : Adding input device with name 7
11-20 12:18:18.886 7238 13569 I SDL/APP : Adding input device with name 8
11-20 12:18:18.886 7238 13569 I SDL/APP : Adding input device with name 9
11-20 12:18:18.886 7238 13569 I SDL/APP : Adding output device with name 2
11-20 12:18:18.888 7238 13569 V hidapi : initialize(true, false)
11-20 12:18:18.898 7238 13569 E SysDVRLogger: Initializing app
11-20 12:18:18.898 7238 13569 E SysDVRLogger:
11-20 12:18:18.900 7238 13569 E SysDVRLogger: Loading resource fonts/NotoSansSC-Regular.ttf
11-20 12:18:18.900 7238 13569 E SysDVRLogger:
11-20 12:18:19.133 7238 13569 E SysDVRLogger: Resource loaded with size 10560380
11-20 12:18:19.133 7238 13569 E SysDVRLogger:
11-20 12:18:19.154 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer dd6c87c0
11-20 12:18:19.154 7238 13569 E SysDVRLogger:
11-20 12:18:20.072 7238 13569 V SDL : setOrientation() requestedOrientation=13 width=1280 height=720 resizable=true hint=
11-20 12:18:20.076 7238 13569 D mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
11-20 12:18:20.076 7238 13569 I SDL/APP : pixel format wanted SDL_PIXELFORMAT_RGBX8888 (2), got SDL_PIXELFORMAT_RGBX8888 (2)
11-20 12:18:20.081 7238 13569 E SysDVRLogger: Initialized SDL with opengles2 renderer
11-20 12:18:20.081 7238 13569 E SysDVRLogger:
11-20 12:18:31.359 7238 13569 E SysDVRLogger: Loading resource strings/Italian.json
11-20 12:18:31.359 7238 13569 E SysDVRLogger:
11-20 12:18:31.361 7238 13569 E SysDVRLogger: Resource loaded with size 12369
11-20 12:18:31.361 7238 13569 E SysDVRLogger:
11-20 12:18:31.362 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e1846000
11-20 12:18:31.362 7238 13569 E SysDVRLogger:
11-20 12:18:31.362 7238 13569 E SysDVRLogger: Loading resource strings/english.json
11-20 12:18:31.363 7238 13569 E SysDVRLogger:
11-20 12:18:31.364 7238 13569 E SysDVRLogger: Resource loaded with size 11808
11-20 12:18:31.364 7238 13569 E SysDVRLogger:
11-20 12:18:31.364 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e1846000
11-20 12:18:31.364 7238 13569 E SysDVRLogger:
11-20 12:18:31.365 7238 13569 E SysDVRLogger: Loading resource strings/french.json
11-20 12:18:31.365 7238 13569 E SysDVRLogger:
11-20 12:18:31.365 7238 13569 E SysDVRLogger: Resource loaded with size 13613
11-20 12:18:31.365 7238 13569 E SysDVRLogger:
11-20 12:18:31.366 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e184b800
11-20 12:18:31.366 7238 13569 E SysDVRLogger:
11-20 12:18:31.366 7238 13569 E SysDVRLogger: Loading resource strings/german.json
11-20 12:18:31.366 7238 13569 E SysDVRLogger:
11-20 12:18:31.366 7238 13569 E SysDVRLogger: Resource loaded with size 12636
11-20 12:18:31.367 7238 13569 E SysDVRLogger:
11-20 12:18:31.367 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e17b5000
11-20 12:18:31.367 7238 13569 E SysDVRLogger:
11-20 12:18:31.367 7238 13569 E SysDVRLogger: Loading resource strings/polish.json
11-20 12:18:31.367 7238 13569 E SysDVRLogger:
11-20 12:18:31.367 7238 13569 E SysDVRLogger: Resource loaded with size 12412
11-20 12:18:31.367 7238 13569 E SysDVRLogger:
11-20 12:18:31.368 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e17b8800
11-20 12:18:31.368 7238 13569 E SysDVRLogger:
11-20 12:18:31.368 7238 13569 E SysDVRLogger: Loading resource strings/portuguese.json
11-20 12:18:31.368 7238 13569 E SysDVRLogger:
11-20 12:18:31.369 7238 13569 E SysDVRLogger: Resource loaded with size 12328
11-20 12:18:31.369 7238 13569 E SysDVRLogger:
11-20 12:18:31.369 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e184f000
11-20 12:18:31.369 7238 13569 E SysDVRLogger:
11-20 12:18:31.370 7238 13569 E SysDVRLogger: Loading resource strings/pt-BR.json
11-20 12:18:31.370 7238 13569 E SysDVRLogger:
11-20 12:18:31.371 7238 13569 E SysDVRLogger: Resource loaded with size 12971
11-20 12:18:31.371 7238 13569 E SysDVRLogger:
11-20 12:18:31.371 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e1852800
11-20 12:18:31.371 7238 13569 E SysDVRLogger:
11-20 12:18:31.371 7238 13569 E SysDVRLogger: Loading resource strings/spanish.json
11-20 12:18:31.371 7238 13569 E SysDVRLogger:
11-20 12:18:31.372 7238 13569 E SysDVRLogger: Resource loaded with size 12755
11-20 12:18:31.372 7238 13569 E SysDVRLogger:
11-20 12:18:31.373 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e1856000
11-20 12:18:31.373 7238 13569 E SysDVRLogger:
11-20 12:18:31.373 7238 13569 E SysDVRLogger: Loading resource strings/zh-CN.json
11-20 12:18:31.373 7238 13569 E SysDVRLogger:
11-20 12:18:31.374 7238 13569 E SysDVRLogger: Resource loaded with size 10616
11-20 12:18:31.374 7238 13569 E SysDVRLogger:
11-20 12:18:31.374 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e185c000
11-20 12:18:31.374 7238 13569 E SysDVRLogger:
11-20 12:18:31.374 7238 13569 E SysDVRLogger: Loading resource strings/zh-TW.json
11-20 12:18:31.374 7238 13569 E SysDVRLogger:
11-20 12:18:31.375 7238 13569 E SysDVRLogger: Resource loaded with size 10872
11-20 12:18:31.375 7238 13569 E SysDVRLogger:
11-20 12:18:31.375 7238 13569 E SysDVRLogger: Freeing the unmanaged resource buffer e185f000
11-20 12:18:31.375 7238 13569 E SysDVRLogger:
11-20 12:18:45.098 7238 13569 E SysDVRLogger: [Video stream] 连接到Switch (尝试 0 或者 5
11-20 12:18:45.098 7238 13569 E SysDVRLogger:
11-20 12:18:45.099 7238 13569 E SysDVRLogger: [Audio stream] 连接到Switch (尝试 0 或者 5
11-20 12:18:45.099 7238 13569 E SysDVRLogger:
11-20 12:18:45.954 7238 13696 E SysDVRLogger: Console memory report: result 0
11-20 12:18:45.954 7238 13696 E SysDVRLogger: Application pool: total=3444572160 used=1301630976 (37.79% used)
11-20 12:18:45.954 7238 13696 E SysDVRLogger: Applet pool: total=516947968 used=103108608 (19.95% used)
11-20 12:18:45.954 7238 13696 E SysDVRLogger: System pool: total=250773504 used=240087040 (95.74% used)
11-20 12:18:45.954 7238 13696 E SysDVRLogger: SystemUnsafe pool: total=46268416 used=44273664 (95.69% used)
11-20 12:18:45.954 7238 13696 E SysDVRLogger:
11-20 12:18:46.048 7238 13696 E SysDVRLogger: Console memory report: result 0
11-20 12:18:46.048 7238 13696 E SysDVRLogger: Application pool: total=3444572160 used=1301630976 (37.79% used)
11-20 12:18:46.048 7238 13696 E SysDVRLogger: Applet pool: total=516947968 used=103108608 (19.95% used)
11-20 12:18:46.048 7238 13696 E SysDVRLogger: System pool: total=250773504 used=240087040 (95.74% used)
11-20 12:18:46.048 7238 13696 E SysDVRLogger: SystemUnsafe pool: total=46268416 used=44273664 (95.69% used)
11-20 12:18:46.048 7238 13696 E SysDVRLogger:
11-20 12:18:46.059 7238 13569 E SysDVRLogger: 使用编解码器初始化视频播放器h264_mediacodec.
11-20 12:18:46.060 7238 13569 E SysDVRLogger:
11-20 12:18:46.060 7238 13569 E SysDVRLogger: Setting strict compliance to experimental for the decoder.
11-20 12:18:46.060 7238 13569 E SysDVRLogger:
11-20 12:18:46.061 7238 13569 E SysDVRLogger: Call in CreateDecoderContext failed: -542398533 Couldn't open the codec.
11-20 12:18:46.061 7238 13569 E SysDVRLogger:
11-20 12:18:46.061 7238 13569 E SysDVRLogger: Player creation failed
I think that means the codec is not supported on your OS or maybe it has not been compiled in the ffmpeg build. Sysdvr still uses some outdatet builds from https://github.com/arthenica/ffmpeg-kit maybe you need to make a custom build with support for those codecs or read the docs for any missing requirements.