discord-screenaudio
discord-screenaudio copied to clipboard
Stream FPS suffers immensely when streaming intensive games
I took interest in this as I like to stream games to my friend group sometimes but the official client still doesn't support audio. For 3/4 of the games I tested, the stream's FPS was extremely low when wandering in areas that otherwise show up just fine on the official client. As expected, choosing lower streaming resolutions helps alleviate this, but it doesn't go away completely.
For reference, I am running this on Arch Linux on kernel 5.19.9, client was built from the AUR.
I think it's because lack of hardware acceleration on discord web version and desktop version on linux.
Just wanted to raise this as well. CPU usage increases from 30 to around 75% when streaming, so GPU is indeed unused. (So playing a game becomes unbearable, as the actual framerate is like 30 instead of 120fps. Oddly enough mangohud stays around 110, which the input lag alone disproves)
Is there a way to enable hardware acceleration? Since it is electron/chrome based, are there flags one can enable for VA-API or whatever it is called?
Judging from https://wiki.qt.io/QtWebEngine/VideoAcceleration I don't think this can be fixed easily, but I could be wrong
i am not very good at any of this but from the documentation in the QtWebEngine wiki maltejur sent there is this https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/209204/ Edit: Looking at the link maltejur sent better, this is talking about 2020, and qt 5.8 (?) maybe useful link is https://github.com/GarageGames/Qt/tree/master/qt-5/qtwebengine/src/3rdparty/chromium/content/common/gpu/media i can see there is some things for va-api support, but again, i am very bad at this so take that with a grain of salt
I feel as though this issue should get more attention, this can be a real deal breaker even if there is working audio. For viewers, having the stream at an uncomfortable stutter dependent on hardware can be a real drag for watch-ability.
Hm judging from the qt bug report there is not much I can do about that. But I have found one promising solution/hack in a issue from qutebrowser.
I have put my code on the testing_hardware_accel branch. Can somebody who experiences lags try out that code and see if it gets any better?
Hm judging from the qt bug report there is not much I can do about that. But I have found one promising solution/hack in a issue from qutebrowser.
I have put my code on the testing_hardware_accel branch. Can somebody who experiences lags try out that code and see if it gets any better?
Hi, I've just tried the client, built from that branch. There seems to be no difference in performance between it and the main branch, the performance drop still persists.
I'll have to test how it works when I can screenshare. Using KDE+Wayland just causes a blank screen, so I have to use X.Org
I have tested it myself, and from people viewing my stream, it's still very choppy.
Hm ok then there is nothing I can really do.
uhhh i checked out the flags that you added, but some are missing for example those are some of the ones i use with my chrome/chromium and without them decoding doesnt work "--ignore-gpu-blacklist --enable-gpu-rasterization --enable-smooth-scrolling --disable-software-rasterizer" "--disable-features=UseOzonePlatform,UseChromeOSDirectVideoDecoder,UseChromeOSDirectVideoEncoder" "--enable-gpu-compositing --enable-drdc --enable-raw-draw" "--disable-gpu-driver-bug-workarounds --disable-gpu-driver-workarounds" "--enable-native-gpu-memory-buffers --num-raster-threads=8 --enable-accelerated-2d-canvas" "--enable-features=WebRTCPipeWireCapturer,VaapiVideoEncoder,VaapiVideoDecoder,Vulkan,CanvasOopRasterization" "--enable-accelerated-video-decode --enable-accelerated-mjpeg-decode --enable-accelerated-video-encode" i'm pretty sure those are needed for it to somehow work correct me if i'm wrong, also by doing this you now use your gpu to watch streams too technically, and u disable software rasterization so you use your gpu
You can test if you can get hardware acceleration running by setting QTWEBENGINE_CHROMIUM_FLAGS
to those chromium flags.
The interesting part is that even with what I consider high end specs my stream also has complaints of lag from viewers at times even just in the browser playing video let alone gaming.
CPU: AMD Ryzen 5800X
GPU: AMD 6700XT
Using Flatpak discord-screenaudio
@rowbawts are you sure this is not caused by your internet connection? Do you have a high CPU usage? If I stream 1080p on the official discord client my stream is also quite laggy.
@rowbawts are you sure this is not caused by your internet connection? Do you have a high CPU usage? If I stream 1080p on the official discord client my stream is also quite laggy.
Edit: I just tested screen sharing from my Macbook and it has no issue so it's not my network and my desktop running Windows 11 also has no issues so I don't think it's the hardware.
If I use OBS I have no issues. The screenshot below is CPU usage while streaming with discord-screenaudio.
@rowbawts are you streaming on the same resolution and FPS in the official client and here?
But if this is indeed not the issue I see that something should be done here, I just don't know what. The official Qt wiki states that video acceleration is not supported and testing out some command line flags has not worked for me either.
@maltejur Yeah every time I do 1080p 60fps but even when trying other lower settings the same issue occurs. But I completely understand, If you end up figuring out a way to enable hw accel it should definitely improve.
i got hardware acceleration to work, sadly for decoding only, those are the flags i used, also bear in mind i'm using the va-api feature
curious how many of the flags are getting ignored, also, if i change num-raster-threads it doesn't get any higher
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--ignore-gpu-blacklist --enable-gpu-rasterization " "--enable-accelerated-video-decode --enable-accelerated-video-encode " "--enable-native-gpu-memory-buffers --num-raster-threads=4 " "--enable-features=WebRTCPipeWireCapturer,VaapiVideoEncoder,VaapiVideoDecoder " "--disable-features=UseOzonePlatform,UseChromeOSDirectVideoDecoder,UseChromeOSDirectVideoEncoder " + qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
I tested this by watching a video with lowered cpu clock speeds so usage would be higher, and monitoring my gpu through green with envy, sadly as i said this only works for hardware decoding, it seems
I can't figure how could I set flags.
Not a solution, but firefox works way better for me with intensive games. Inspired by this project, I created this extension for firefox. It is not packaged for any distro, I'm open to contributions though!
Still no news on working GPU hardware acceleration?
Two things I'm curious about. (Wayland Specific)
- OBS somehow is able to capture the screen with no impact to the game, and at a high refresh rate. How?
- Maybe discord-screenaudio can create a local rtmp server, and use the contents from there to stream to discord? That way we can use OBS to actually capture the frames (?)
Things got a little weird lately.
flatpak vanilla discord com.discordapp.Discord
started is working for screensharing video from individual games/windows quite well. Hardware Acceleration and video codec OPENH264 are enabled - which results in a smooth video stream. Problem is no audio.
flatpak discord-screenaudio
while the audio is working, does not show hardware acceleration. Problem is unwatchable choppy video.
Too bad I can't get both, smooth video and audio. I don't know enough about what's going on, but for video I need hardware acceleration / H264 to be watchable.
I've tried this in both X11/wayland scenarios. GPU is AMD 5700 XT