teams-for-linux icon indicating copy to clipboard operation
teams-for-linux copied to clipboard

Possible guide to enable HW DEcoding and ENcoding in electron

Open D-MLink opened this issue 1 year ago • 10 comments

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

D-MLink avatar Jul 01 '24 08:07 D-MLink

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 https://github.com/electron/electron/issues/35392 . We use electron 29 (Just upgraded to 30 today) so this should be well supported.

Thanks for the link and the info!

IsmaelMartinez avatar Jul 08 '24 08:07 IsmaelMartinez

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

D-MLink avatar Jul 08 '24 09:07 D-MLink

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"] ]

D-MLink avatar Jul 10 '24 07:07 D-MLink

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 ;)

raul-klg avatar Jul 10 '24 08:07 raul-klg

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

D-MLink avatar Jul 11 '24 08:07 D-MLink

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.

IsmaelMartinez avatar Jul 11 '24 22:07 IsmaelMartinez

I'm also still struggling with this (as reported in https://github.com/IsmaelMartinez/teams-for-linux/issues/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?

donjan avatar Aug 07 '24 14:08 donjan

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

IsmaelMartinez avatar Aug 16 '24 18:08 IsmaelMartinez

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.

mirenradia avatar Aug 23 '24 08:08 mirenradia

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.

github-actions[bot] avatar Oct 16 '24 08:10 github-actions[bot]

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.

github-actions[bot] avatar Nov 26 '24 09:11 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Dec 02 '24 09:12 github-actions[bot]

Still cannot be resolved

tetap avatar Dec 03 '24 11:12 tetap

so, i am currently trying to get hardware acceleration working under ubuntu 24.04 + gnome + wayland with a 7840u.

running chrome from the command-line: google-chrome --use-gl=angle --use-angle=vulkan \ --enable-features=AcceleratedVideoEncoder,VaapiOnNvidiaGPUs,VaapiIgnoreDriverChecks,Vulkan,DefaultANGLEVulkan,VulkanFromANGLE \ --ignore-gpu-blocklist --disable-gpu-driver-bug-workaround

results in about:gpu showing hardware accel for encode / decode and the resource monitor shows a video encoder/decode usage of about 6/7%.

setting those same flags in config.json seems to have no effect for teams-for-linux, which is not completely unexpected, as electron does not support those flags: https://www.electronjs.org/docs/latest/api/command-line-switches

but i might be missing something... ;-)

universal avatar Jun 20 '25 12:06 universal

This has been broken for me for the past few months despite working some time ago. I'm not sure what changed but my guess would be something in electron.

mirenradia avatar Jun 20 '25 21:06 mirenradia

{
    "electronCLIFlags": [
        ["use-gl", "angle"],
        ["use-angle", "vulkan"],
        ["enable-features", "AcceleratedVideoEncoder,VaapiOnNvidiaGPUs,VaapiIgnoreDriverChecks,Vulkan,DefaultANGLEVulkan,VulkanFromANGLE"],
        "ignore-gpu-blocklist",
        "disable-gpu-driver-bug-workaround"
    ]
}

after fixing some typo, this seems to result in encoder/decoder being used. though video appears to freeze sometimes...

universal avatar Jun 23 '25 07:06 universal

{ "electronCLIFlags": [ ["use-gl", "angle"], ["use-angle", "vulkan"], ["enable-features", "AcceleratedVideoEncoder,VaapiOnNvidiaGPUs,VaapiIgnoreDriverChecks,Vulkan,DefaultANGLEVulkan,VulkanFromANGLE"], "ignore-gpu-blocklist", "disable-gpu-driver-bug-workaround" ] }

after fixing some typo, this seems to result in encoder/decoder being used. though video appears to freeze sometimes...

Thanks, this worked for me to get HW video processing working (I removed VaapiOnNvidiaGPUs since I don't have an Nvidia GPU).

mirenradia avatar Jun 23 '25 16:06 mirenradia

Thanks, this worked for me to get HW video processing working

How did you verify that ?

matikij avatar Jul 24 '25 10:07 matikij

OK, I re-read the first message here - you can verify that in three dots -> Settings -> Call health when on a call

matikij avatar Jul 24 '25 10:07 matikij