Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible guide to enable HW DEcoding and ENcoding in electron #1324

Open
D-MLink opened this issue Jul 1, 2024 · 10 comments
Open

Possible guide to enable HW DEcoding and ENcoding in electron #1324

D-MLink opened this issue Jul 1, 2024 · 10 comments

Comments

@D-MLink
Copy link

D-MLink commented Jul 1, 2024

From using teams4linux daily i notice my laptop goes into turbo mode whenever i enter a call and everyone turns on their cameras (and I have to turn on mine)
The teams v2 has a call health feature and displays that the videos are decrypted using SW.

Looking to solve my issue, i tried to force enable HW encoding on chromium. Managed to do it but my video comes out with artifacts... But the performance improved.
image

So I found this repo: https://github.com/StaZhu/enable-chromium-hevc-hardware-decoding which may help to enable HW encoding/decoding in electron. I know it talks about hevc and teams uses h264, but there might something that helps enabling both.

For reference, my work laptop is running Pop!_OS 22.04 on a i7-10610U

@IsmaelMartinez
Copy link
Owner

You should be able to use the ['enable-features', 'PlatformHEVCDecoderSupport'] like in https://github.com/IsmaelMartinez/teams-for-linux/tree/develop/app/config#electron-cli-flags . I haven't test it but that would enable that flag as described in electron/electron#35392 . We use electron 29 (Just upgraded to 30 today) so this should be well supported.

Thanks for the link and the info!

@D-MLink
Copy link
Author

D-MLink commented Jul 8, 2024

Thanks for the config option, but so far I tried several flags, including the ones I use to make it work on chromium, and I still get SW video processing on Teams for linux

@IsmaelMartinez IsmaelMartinez reopened this Jul 8, 2024
@D-MLink
Copy link
Author

D-MLink commented Jul 10, 2024

Here's the config I tried for reference:
"electronCLIFlags":[ ["ignore-gpu-blocklist"], ["enable-zero-copy"], ["enable-features", "WebRTCPipeWireCapturer,PlatformHEVCDecoderSupport,CanvasOopRasterization,VaapiIgnoreDriverChecks,VaapiVideoDecoder,VaapiVideoEnco> ["enable-accelerated-video-decode"], ["disable-features","UseChromeOSDirectVideoDecoder"] ]

@raul-klg
Copy link

raul-klg commented Jul 10, 2024

Hi!
I'm also pursuing this feature, and I think there has been a mistake pasting the configuration, I think you meant:

    "electronCLIFlags": [
        ["ignore-gpu-blocklist"],
        ["enable-zero-copy"],
        ["enable-features", "WebRTCPipeWireCapturer,PlatformHEVCDecoderSupport,CanvasOopRasterization,VaapiIgnoreDriverChecks,VaapiVideoDecoder,VaapiVideoEncoder"],
        ["enable-accelerated-video-decode"],
        ["disable-features","UseChromeOSDirectVideoDecoder"]
	]

right?

Also, in order to check if GPU decoding is enabled I'd like to follow these troubleshoot steps but I don't know how to get there in the t4l window. Hints appreciated ;)

@D-MLink
Copy link
Author

D-MLink commented Jul 11, 2024

Hi! I'm also pursuing this feature, and I think there has been a mistake pasting the configuration, I think you meant:

    "electronCLIFlags": [
        ["ignore-gpu-blocklist"],
        ["enable-zero-copy"],
        ["enable-features", "WebRTCPipeWireCapturer,PlatformHEVCDecoderSupport,CanvasOopRasterization,VaapiIgnoreDriverChecks,VaapiVideoDecoder,VaapiVideoEncoder"],
        ["enable-accelerated-video-decode"],
        ["disable-features","UseChromeOSDirectVideoDecoder"]
	]

right?

Also, in order to check if GPU decoding is enabled I'd like to follow these troubleshoot steps but I don't know how to get there in the t4l window. Hints appreciated ;)

yes! i copied from the nano windows and missed also the VaapiVideoDecodeLinuxGL feature flag
I also dont know how to open the chrome:gpu window

@IsmaelMartinez
Copy link
Owner

IsmaelMartinez commented Jul 11, 2024

I wonder if it is worth opening an issue/question in the electron repository. Maybe some of those flags aren't supported. Or check on running from source (check the contributing.md file). Maybe is the bundling that is blocking some areas... but I would suspect is electron land issue/limitation.

@donjan
Copy link

donjan commented Aug 7, 2024

I'm also still struggling with this (as reported in #1246). Teams pair programming on that particular laptop (ThinkPad X1C 8th Gen) is a punishment.

My current settings are essentially the same as other's above:
~/.config/teams-for-linux/config.json

{
    "electronCLIFlags": [
        ["ignore-gpu-blocklist"],
        ["enable-zero-copy"],
        ["enable-accelerated-video-decode"],
        ["enable-features", "WebRTCPipeWireCapturer,PlatformHEVCDecoderSupport,CanvasOopRasterization,VaapiIgnoreDriverChecks,VaapiVideoDecoder,VaapiVideoEncoder,VaapiVideoDecodeLinuxGL"],
        ["disable-features","UseChromeOSDirectVideoDecoder"]
    ]
}

How can I check if these settings even get consumed?

...

Now... to get a bit off of Ismael's back, I have to admit I'm apparently struggling with basic Chromium acceleration already.

When launching the browser with

chromium-browser --ignore-gpu-blocklist --enable-zero-copy --enable-accelerated-video-decode --enable-features=WebRTCPipeWireCapturer,PlatformHEVCDecoderSupport,CanvasOopRasterization,VaapiIgnoreDriverChecks,VaapiVideoDecoder,VaapiVideoEncoder,VaapiVideoDecodeLinuxGL --disable-features=UseChromeOSDirectVideoDecoder

And checking about:gpu, I get two promising sections:

1
2

Which means I can't hardware-decode AV1, YouTube's default for most videos, but I can force H264 with the h264ify extension (which works correctly, checking "stats for nerds"). Yet despite what the images above might imply, intel_gpu_top shows no bar for the video line when playing a H264 video, and there is massive CPU usage.
It does use video in Firefox and mpv, with nicer CPU usage, so my hardware & OS can in fact accelerate the decoding.
Chromium 101.0.4951.15 on Ubuntu 22.04.4 can't.
I don't want to derail this too much, but can anyone reproduce this underlying issue?

@IsmaelMartinez
Copy link
Owner

have you check in the electron issues https://github.com/electron/electron/issues ? This might be something other users of electron have experienced. Hopefully something in there helps you. Sorry

@mirenradia
Copy link

mirenradia commented Aug 23, 2024

I think HW processing is now enabled for me with the electronCLIFlags config option suggested above (Intel Alder Lake iGPU). I noticed that it only worked with no effects enabled and reverted back to SW processing when I enabled the blur effect.

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants