RPi-Distro / chromium-browser

30 stars 7 forks source link

h.264 video playback is not hardware accelerated #44

Closed matt-oakes closed 3 months ago

matt-oakes commented 3 months ago

The version of Chromium which ships in Raspberry Pi OS should be patched to enable hardware accelerated video playback. There seems to be a problem with this patch as Chromium attempts to use a hardware accelerated decoder VDAVideoDecoder before getting an error and falling back to the software based decoder FFmpegVideoDecoder.

To reproduce this you need to open the Chromium Dev Tools, open the "Media" panel (which is inside "More tools" in the context menu), and then play a h.264 encoded video file.

When you do this you will see it first pick the VDAVideoDecoer before erroring and falling back to the FFmpegVideoDecoder. The output will look something like this (apologies for the poor quality screenshot, it's going through a USB HDMI capture card):

Screenshot 2024-06-04 at 16 54 06 Screenshot 2024-06-04 at 16 53 40

The error is reported as VDA Error 4 which corresponds to PLATFORM_ERROR in the error enum of the Chromium source. Unfortunatly, this isn't very specific and could be thrown from a few different places in the Chromium code.

The only errors that I can see in the console when running Chromium are these:

[18556:18794:0604/172019.835330:ERROR:v4l2_video_decode_accelerator.cc(2281)] Failed allocating input buffers
[18556:18794:0604/172019.837246:ERROR:v4l2_video_decode_accelerator.cc(305)] Failed CreatingInputBuffers()

There is no additional information in the chrome-debug.log file even with --enable-logging --v=5 set.

matt-oakes commented 3 months ago

I have updated everything and tried this again. It seems like this does work correctly with the patched Chromium 124 version. It was the 122 version which was broken.

The cause seemed to be that the kUseChromeOSDirectVideoDecoder flag was patched to disabled by default on 122 and no longer is on 124. This was causing this check to pass by default and for VDAVideoDecoder to be used rather than V4L2VideoDecorder.

This is working fine in the latest 124 patched version so I will close this issue.