protonscr

Game recording have a very significant performance penalty compared to Windows or OBS in Linux

steamopen overlay
ValveSoftware/steam-for-linux#11166 · opened 2024-08-08 by MegWATTT · updated 2024-12-23 · 16 comments · github
MMegWATTT 2024-08-08 github

Your system information

  • Steam client version (build number or date): 1722380543
  • Distribution (e.g. Ubuntu): Ubuntu 24.04 (Plasma wayland) (also tested on GNOME wayland)
  • Opted into Steam client beta?: Yes
  • Have you checked for system updates?: Yes
  • GPU: AMD RX 6700 10GB

Please describe your issue in as much detail as possible:

Enabling background game recording have a very significant impact on performance, with a much higher GPU usage than expected, even when VAAPI is disabled. Using a lower bitrate doesn't seems to a big difference in performance. However, recording at 30FPS instead of 60 have a significant benefice.

Below is a chart I've made by testing the impact of performance while recording. The game used is Dead By Daylight, on the main menu with the same settings on all tests. The game have a max framerate of 120 FPS and is almost GPU limited on this scene with no recording. The resolution of my screen and the game is 2560x1440. I selected a bitrate of 7.5K on steam and OBS. OBS uses Pipewire to acquire frames from the game.

MangoHud is used on Linux to monitor FPS, GPU load and power consumption while Afterburner is used on Windows. When GPU limited, the power consumption of my GPU is at most at 158W.

Settings FPS GPU Load (~%) GPU power consumption (W)
Steam_Lnx_NoRecording 120 94 158
Steam_Lnx_30FPS_VAAPI 83 94 143
Steam_Lnx_30FPS_CPU 102 93 144
Steam_Lnx_60FPS_VAAPI 59 99 124
Steam_Lnx_60FPS_CPU 70 98 136
OBS_Lnx_30FPS_VAAPI 117 99 158
OBS_Lnx_30FPS_CPU 120 98 158
OBS_Lnx__60FPS_VAAPI 111 99 158
OBS_Lnx_60FPS_CPU 119 99 158
Steam_Win_NoRecord 120 95 157.0
Steam_Win_60FPS_HwAccel 113 97 158.0
Steam_Win_60FPS_CPU 116 97 157.0

When recording with steam, especially on 60FPS, the GPU power consumption is significantly below than 158W while still having a high GPU load. The only time I had this scenario is when running out of VRAM (this is not the case here). I suspect that acquiring frames from the game is way less efficient than on OBS or Steam recorder on Windows.

For instance, during the loading screen, I have a situation where the GPU load is far higher than expected while power consumption very low while recording:
GPU_load

On top of that, the framerate consistency feels very bad, especially on 60 FPS recording and makes the playing experience unpleasant.

I've also tested with MangoHud disabled to see if it have an impact of performance, with no success.

AAQDuck97 2024-11-06 github

Can confirm this as well on Arch Linux with latest stable Steam.
I have two GPUs in my system, one AMD that runs the desktop and one Nvidia I use for games. I tried running Steam with prime-run to ensure it's using the Nvidia card but still the same horrible performance.

Other recorders that uses GPU (GPU Screen Recorder* and OBS**) works perfectly fine

* GSR uses AMD card by default but if I run it with prime-run it's using the Nvidia card
** OBS still relies heavily on CPU on Linux, but that's an OBS Linux issue

Uurbenlegend 2024-11-06 github

Same here. I am running an Nvidia 3090 with 565.57.01 drivers on KDE Wayland and the moment screen recording starts, all my games suffer a big 10-20fps drop.

Is NVENC / CUDA being leveraged here or are we falling back to software encoding? Are there logs where I can check what is actually being used?

Ddec05eba 2024-11-07 github

@urbenlegend start steam from the terminal. When you start a game (with steam recorder enabled) it should tell you which encoder it uses. Last time I checked it used software encoding (libx264) on nvidia on linux.

Uurbenlegend 2024-11-07 github

@dec05eba Yes you're right. I just captured two logs, one in Wayland and one in X11, and in both of them it says it attempted to use NVENC but failed. Then it tried to use VA-API, but that also failed. Finally it fellback on x264. Seems like the NVENC integration needs work.

Here are the logs:
encoding-log-wayland.txt
encoding-log-x11.txt

AAQDuck97 2024-11-07 github

Including my log too: Gist

PPC-Heini 2024-11-13 github

I am running Open Suse Tumbleweed and Steam either falls back to software encoding or exports a 0 second clip, depending on the game. My GPU is a AMD Radeon RX 6950 XT.

Steam console output when starting a manual game recording:
libav: Failed to initialise VAAPI connection: -1 (unknown libva error). CGameStreamVideoStageVAAPI: Failed to create device context: Input/output error Failed to pre-process frame Encoder stage failed [type=5, codec=4] Building new pipeline Trying to create an encoder for recording: [hardware_enabled=true][hardware_suppressed=false] Failed encoders: 2/4, 4/4, 5/4 Created encoder X264 for codec 4 Detected 16 logical processors, using 4 threads Configuring encoder: [threads=4][width=1920][height=1080][preset=veryfast][tune=film] Video Encoder Changed

Ddec05eba 2024-11-13 github

@PC-Heini I believe the issue on opensuse is because opensuse is one of the few distros that disables hardware accelerated encoders on amd for h264 and hevc. Some other corporate distros such as fedora and manjaro does this as well. One way to fix this is to use the flatpak version of steam as flatpak doesn't have this issue.

Gghtux 2024-11-13 github

On Manjaro it isn´t disabled anymore (on arch neither). The vaapi error may be caused by missing packages. Install lib32-mesa driver and lib32-libva and try again. Steam expects x32 libs in some cases.

PPC-Heini 2024-11-13 github

@dec05eba I think I have the necessary repos enabled but you are right, OpenSuse does not have many of the common codecs in the repos it ships with.

@ghtux I think this is my problem, but I can't find a 32 bit version of the package. All the other Mesa packages have the suffix -32bit but Mesa-libva-32bit doesn't exist.

Zypper search output

Gghtux 2024-11-14 github

https://en.opensuse.org/Steam#Failure_to_start_Steam,_when_trying_to_load_Steam_without_local_runtime

This looks promising:

user $ sudo zypper in libvdpau_radeonsi-32bit (for radeon cards) libXtst6-32bit libvdpau_va_gl1-32bit libva-glx2-32bit

Zzainin 2024-11-14 github

For other people that might have this error in their logs:
libav: Failed to initialise VAAPI connection: -1 (unknown libva error).

In my case it was caused by a missing package on Arch: lib32-libva-mesa-driver (which is pretty weird, because I'd swear initially recording worked fine right after it was released in beta).

Aask-compu 2024-11-25 github

i see similar errors as well as NVENC - Submitting frame for encoding failed: 20

i'm on Kubuntu 22.04 with an RTX 2080 Ti and the nvidia driver 550.120

also game recording seems to just fail entirely in one specific game (Stormworks) and i can see nothing in the logs as to why

NVENC works perfectly fine when i use it in ffmpeg or OBS tho

Uurbenlegend 2024-12-14 github

I tested NVENC again today and now Steam seems to be able to create the encoder and use it for encoding!

Created encoder NVENC for codec 4
Video Encoder Changed
>>> Saw first frame, starting a session
Game Recording - Recording Started [recording=fg_2074920_20241214_201320]
>>> Recording new resolution 1920x1080 using bitrate 12000kbps
>>> Capture method set to Game Vulkan NV12 + NVENC H264
>>> First video pts is 31945.047434s, first video PTS is 0.032725s
Manual recording for game 2074920, no retention interval
>>> First audio pts is 31945.422996s
>>> Audio deltas: first audio frame 31945.422996s, first video frame 31945.047434s, first video PTS 0.032725s. Resulting first audio sample is 18027 (0.375563s)

Not sure what changed and whether there was a sneaky Steam patch that fixed it, but performance feels slightly better. The capture-rate is a lot smoother, where as before the final video had a lot of dropped frames. However, I am still seeing a big FPS drop whenever capture is enabled. In The First Descendant, my FPS goes from 50fps to 38fps.

So the situation seems to be improving, but there's still performance left on the table.

Operating System: Arch Linux
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.9.0
Qt Version: 6.8.1
Kernel Version: 6.12.4-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 24 × AMD Ryzen 9 3900X 12-Core Processor
Memory: 31.3 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 3090/PCIe/SSE2 w/ 565.77 drivers
Product Name: X570 Taichi

Aask-compu 2024-12-14 github

i see similar errors as well as NVENC - Submitting frame for encoding failed: 20

i'm on Kubuntu 22.04 with an RTX 2080 Ti and the nvidia driver 550.120

also game recording seems to just fail entirely in one specific game (Stormworks) and i can see nothing in the logs as to why

NVENC works perfectly fine when i use it in ffmpeg or OBS tho

NVENC works for me too but the problem with game recording for stormworks still persists

Llorkanoo 2024-12-16 github

For fedora (AMD), to install driver which contains needed codecs for hardware acceleration, follow RPM Fusion steps:
Hardware codecs with AMD (mesa) -> "If using i686 compat libraries (for steam or alikes)"
After this steam initializes hardware acceleration correctly, but there is still around ~12% GPU performance overhead from this feature

Sstonedtemplepilot 2024-12-23 github

@dec05eba I think I have the necessary repos enabled but you are right, OpenSuse does not have many of the common codecs in the repos it ships with.

@ghtux I think this is my problem, but I can't find a 32 bit version of the package. All the other Mesa packages have the suffix -32bit but Mesa-libva-32bit doesn't exist.

Zypper search output

Go into Yast Software Management, search for libva and enable/install libva2-32bit.
This solved the issue for me in Steam and I managed to get VA-API encoding to work.
I'm not sure if it's required but I also installed libva-drm2-32bit.

image

Trying to create an encoder for recording: [hardware_enabled=true][hardware_suppressed=false]
Allowed Codecs: 4
Created encoder VAAPI for codec 4
CGameStreamVideoStageVAAPI: Reinitializing 2560x1440 at 32000 Kbit/s and 60.00 FPS with quality 1
Video Encoder Changed
>>> Saw first frame, starting a session
Game Recording - Recording Started [recording=fg_553850_20241223_235501]
>>> Recording new resolution 2560x1440 using bitrate 32000kbps
>>> Capture method set to Game Vulkan NV12 + VAAPI H264
>>> First video pts is 49031.578901s, first video PTS is 0.049999s
Manual recording for game 553850, no retention interval
>>> First audio pts is 49031.608960s
>>> Audio deltas: first audio frame 49031.608960s, first video frame 49031.578901s, first video PTS 0.049999s. Resulting first audio sample is 1443 (0.030062s)
GameScope focus changed to appID 0

Nothing extracted yet.