
Electron - Hardware Accelerated Video Playback on Raspberry Pi (RPi)
When playing an HD video in Electron on a Raspberry Pi 4B, playback performance is poor (e.g., audio cuts out after ~3 seconds and CPU usage is high). However, playback is good in the Chromium browser that comes with the RPi OS, demonstrating that a bit more performance is possible.
Let's try to understand why.
Performance Comparison
A YouTube in HD video is used for testing purposes.
To find out which codec is used, in YouTube, right-click on the video, then Stats for nerds.
To find out which decoder is being used, in the Chromium inspector, select the "Media" tool under More tools
. This will then give you access to the information about the currently playing video.
Codec Selection
The codec used is established during a negotiation between the browser and the video provider. The provider issues a list of available codecs, and the browser lists those it supports using the window.MediaSource.isTypeSupported()
function. The codec deemed optimal is then played in the browser.
A platform like YouTube will offer dozens of codec options to the browser, whereas a custom video hosted on a website will usually only offer one or two.
Affected environments
Performance issues occur as of July 29, 2025, with the following configurations:
- Raspberry Pi 4B (not tested on other models)
- Electron versions
34.5.8
,35.7.2
,36.7.3
,37.2.4
, and38.0.0-alpha.11
(on earlier versions, performance is also poor, but the information inchrome://gpu
is different). - Raspberry Pi OS (64-bit), May 13, 2025, Kernel 6.12, Debian 12 (bookworm)
Performance in Chromium
Video playback in the Chromium OS is acceptable. HD video playback on YouTube is smooth and there framedrops are limited. The video is decoded using V4L2VideoDecode
.
By opening the chrome://gpu
page, you'll see Video Decode: Hardware accelerated
.
Performance in Electron
Playing the same video in Electron is much less fluid. By default, the selected codecs are sometimes different and are decoded by the decoder Dav1dVideoDecoder
or FFMpegDecoder
.
By opening the chrome://gpu
page, you'll see Video Decode: Software only. Hardware acceleration disabled
.
On peut aussi forcer les codecs utilisés en utilisant une extension comme h264ify. Des codecs plus similaires sont alors utilisés sur Chromium et dans Electron, facilitant les comparaisons. Bien que, théoriquement, ce soient les mêmes codecs, les performances sont très différentes.
We therefore understand that on Electron, decoding is not done with V4L2VideoDeocde
, as it is on Raspberry Pi OS's Chromium. Instead, it is done by another decoder that is very CPU-intensive and not Hardware accelerated.
Why the performance is so different
After extensive testing and research, no Chromium flag added to Electron is able to enable hardware-accelerated video decoding or improve video playback performance. I tried using the flags mentioned in these articles:
- VaapiVideoDecoder
- UseChromeOSDirectVideoDecoder, use-gl, ignore-gpu-blocklist, enable-accelerated-video-decode
We can understand why it's not a matter of flags by reading the RPi OS source code: the Chromium web browser that ships with the RPi OS has been altered to adapt to the Raspberry Pi's specifities using patches applied to the Chromium build.
What are the possible solutions?
Ideally, Electron (or a third-party) would provide us with a compiled version adapted for the Raspberry Pi, which would include the patches if the application is launched on a RPi. However, this doesn't seem to be in the plans at all.
To achieve an Electron version with performance similar to that obtained in Chromium, we would therefore have to compile our own Electron, which would include the Chromium patches from RPi OS. However, this is not so simple, since compiling such an application is time-consuming (several hours), requires several dependencies, and a powerful computer.
It would be interesting to check performance on a Raspberry Pi 5. Although Hardware Acceleration will not be enabled in Electron either, perhaps its additional CPU performance would allow us to achieve an acceptable result without tinkering.
Ultimately, the simplest solution for optimal video playback performance on the Pi may be to avoid Electron when it is possible and use RPi OS's Chromium in kiosk mode.