flathub / com.dec05eba.gpu_screen_recorder

https://flathub.org/apps/details/com.dec05eba.gpu_screen_recorder
11 stars 4 forks source link

In-game screen tearing when using gpu-screen-recorder #111

Closed artik closed 4 months ago

artik commented 4 months ago

Hi dec05eba,

I noticed in-game screen tearing (v-sync "off" efffect) while recording. The video saved won't be affect, only in-game. When gpu-screen-recording is not recording, I don't have this behavior and each frame is perfectly drown.

Also I'm not sure, but this can also affect specific game (In this case it's Tekken 8).

Do you have any idea if a setting can fix this?

dec05eba commented 4 months ago

This is the wrong place to ask such questions but i'll answer it anyways. But you need to provide information about your system, your gpu (does gpu screen recorder say its recording on nvidia, intel or amd), if you are using x11 or wayland, do you have gsync, which options are you recording with, etc? if you are on x11 i assume you only have one monitor connected and vsync enabled in the game?

artik commented 4 months ago

Thanks for help. I'm trying to provide you as much as info as possible:

My system inxi -Fxz:

System:
  Kernel: 6.5.0-28-generic x86_64 bits: 64 compiler: N/A
    Desktop: Cinnamon 6.0.4 Distro: Linux Mint 21.3 Virginia
    base: Ubuntu 22.04 jammy
Machine:
  Type: Desktop System: ASUS product: N/A v: N/A serial: <superuser required>
  Mobo: ASUSTeK model: ROG MAXIMUS Z690 HERO v: Rev 1.xx
    serial: <superuser required> UEFI: American Megatrends v: 3302
    date: 02/21/2024
CPU:
  Info: 16-core (8-mt/8-st) model: 12th Gen Intel Core i9-12900K bits: 64
    type: MST AMCP arch: Alder Lake rev: 2 cache: L1: 1.4 MiB L2: 14 MiB
    L3: 30 MiB
  Speed (MHz): avg: 800 min/max: 800/5100:5200:3900 cores: 1: 800 2: 800
    3: 800 4: 800 5: 800 6: 800 7: 800 8: 800 9: 800 10: 800 11: 800 12: 800
    13: 800 14: 800 15: 800 16: 800 17: 800 18: 800 19: 800 20: 800 21: 800
    22: 800 23: 800 24: 800 bogomips: 152985
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Graphics:
  Device-1: NVIDIA vendor: Micro-Star MSI driver: nvidia v: 550.67
    bus-ID: 01:00.0
  Display: x11 server: X.Org v: 1.21.1.4 driver: X: loaded: nvidia
    gpu: nvidia resolution: 3440x1440
  OpenGL: renderer: NVIDIA GeForce RTX 4080 SUPER/PCIe/SSE2
    v: 4.6.0 NVIDIA 550.67 direct render: Yes
Audio:
  Device-1: Intel vendor: ASUSTeK driver: snd_hda_intel v: kernel
    bus-ID: 00:1f.3
  Device-2: NVIDIA vendor: Micro-Star MSI driver: snd_hda_intel v: kernel
    bus-ID: 01:00.1
  Device-3: ASUSTek USB Audio type: USB
    driver: hid-generic,snd-usb-audio,usbhid bus-ID: 1-7:6
  Sound Server-1: ALSA v: k6.5.0-28-generic running: yes
  Sound Server-2: PulseAudio v: 15.99.1 running: no
  Sound Server-3: PipeWire v: 1.0.3 running: yes

How to check which gpu is recording on? gpu-screen-recorder -w screen -f 60 -o ~/bureau/temp/"video_$(date +"%F %T")".mp4 gives me:

[hevc_nvenc @ 0x5f6286c55040] ignoring invalid SAR: 0/0
Info: using hevc encoder because a codec was not specified
[hevc_nvenc @ 0x5f6287cbb140] ignoring invalid SAR: 0/0
update fps: 246
update fps: 245
...

I'm using x11 env | grep -E -i 'x11|xorg|wayland'd returns:

XDG_SESSION_TYPE=x11

Gsync is activated and working:

Screenshot-2024-04-25-14-10-06

Some other info:

Screenshot-2024-04-25-14-13-12

ffmpeg --version
ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers

Yes, I only have one monitor, and vsync enabled in the game.

dec05eba commented 4 months ago

In the case of gsync like you have you can use the -w screen-direct-force option as mentioned when you run gpu-screen-recorder --help. That option is kinda hidden like that since the nvidia driver is bugged and using this option can lead to some issues such as your computer freezing if you record some games. Unfortunately nvidia drivers are just bugged like that, but you can try if it works in your case.

artik commented 4 months ago

I tried the -w screen-direct-force but doesn't fix the in-game tearing. Also, i noticed i'm using an old ffmpeg version 4.4.2 (packaged with my distro) Maybe upgrading it could fix this issue ?

dec05eba commented 4 months ago

That shouldn't be the issue, as long as your nvidia driver is recent and it is. Its possible that you dont have gsync configured properly so its not really used. The nvidia settings has an option to show if gsync is working or not, and that can show if gsync state changes when you start recording: https://www.reddit.com/r/linux_gaming/comments/k5w4eu/tutorial_how_to_enable_gsyncfreesync_on_nvidia/ as you can see you also have to disable the compositor when playing the game and allow flipping

artik commented 4 months ago

I have vsync green, but BLIT in red, meaning it runs in compatible mode and don't use GSync. Seems to be a Nvidia Driver bug, once again... Or a cinnamon one: https://github.com/linuxmint/cinnamon/issues/11642

Screenshot-2024-04-25-15-33-26

dec05eba commented 4 months ago

if i recall correctly, vsync doesn't correctly when it's blitting right? even without gsync, so the only reason you aren't seeing tearing is because it just happens to time correctly in the game so you dont see it most of the time

artik commented 4 months ago

Correct, BLIT is bad, should be FLIP (and green). The thing is that when I stop recording, tearing dissapears in my game:

Recording:

Screenshot-2024-04-25-16-13-19

Not recording:

Screenshot-2024-04-25-16-13-44

dec05eba commented 4 months ago

It's just a coincidence that it's working when you are not recording. Any slight change to fps/frame timing will make tearing appear/disappear if you dont have vsync working. So this issue has nothing do with gpu screen recorder specifically. This tearing can happen if your system is just a tiny bit slower. So the only way to fix it is to make sure vsync works properly on your system.

artik commented 4 months ago

Totally agree. Thanks for lighting me on this issue :)

Sturmlocke86 commented 3 months ago

+1 I can confirm this happening on my system too (Ubuntu and openSUSE), but I have never given it much thought because it happens with OBS Studio too. It's the exact same thing in OBS. IIRC there was a discussion about this in the OBS forums and iirc they said it was normal for tearing to appear during recording as long as the exported video does not have any tearing.