Go to file
2022-03-24 19:04:48 +01:00
include Add screen-direct option for direct NvFBC 2022-03-24 00:38:35 +01:00
src Fix replay if no audio stream 2022-03-24 19:04:48 +01:00
.clang-format format code 2020-03-30 17:38:55 +02:00
.gitignore Attempt to fix audio timestamp being totally wrong on fedora 2022-03-23 19:24:12 +01:00
build.sh Use /usr/lib64 instead of /usr/lib, which makes it compatible with gentoo 2022-03-22 00:29:20 +01:00
install_ubuntu.sh Add install script for ubuntu based distros 2022-03-22 13:08:02 +01:00
interactive.sh Remove dependency on sibs for building 2022-01-30 23:24:20 +01:00
LICENSE Update LICENSE 2020-03-30 21:40:41 +02:00
list-sinks.sh Add pulseaudio, parse command line args 2020-06-21 14:41:11 +02:00
project.conf Add script to record the selected window (with the active audio device) 2022-03-22 13:04:08 +01:00
README.md Add screen-direct option for direct NvFBC 2022-03-24 00:38:35 +01:00
replay.sh Remove dependency on sibs for building 2022-01-30 23:24:20 +01:00
TODO Fix fullscreen window forcefully getting unfullscreened on i3 and bspwm 2022-03-24 09:59:04 +01:00
toggle-recording-selected.sh Record black screen instead of crash when compositor + window is not supported at the moment 2022-03-22 13:33:02 +01:00
twitch-stream-local-copy.sh Remove dependency on sibs for building 2022-01-30 23:24:20 +01:00
twitch-stream.sh Remove dependency on sibs for building 2022-01-30 23:24:20 +01:00

gpu screen recorder

This is a screen recorder that has minimal impact on system performance by recording a window using the GPU only, similar to shadowplay on windows. This is the fastest screen recording tool for Linux.

This screen recorder can be used for recording your desktop offline, for live streaming and for nvidia-like instant replay, where only the last few seconds are saved.

Note

Might now work when using a compositor such as picom when using the glx backend. Using the xrender backend with picom fixes this issue.
Does not work when using gtk client side decorations (such as on Pop OS). Either disable those (if possible), install gtk-nocsd or record the whole monitor/screen if you have NvFBC.
NvFBC doesn't work with PRIME, so if you are using PRIME then you can't record the monitor/screen, you have to record a single window.
If you are using a variable refresh rate monitor, then choose to record "screen-direct". This will allow variable refresh rate to work when recording fullscreen applications. Note that some applications such as mpv will not work in fullscreen mode. A fix is being developed for this.

Performance

When recording a 4k game, fps drops from 30 to 7 when using OBS Studio, however when using this screen recorder the fps remains at 30.

Installation

If you are running an Arch Linux based distro, then you can find gpu screen recorder on aur under the name gpu-screen-recorder-git (yay -S gpu-screen-recorder-git).
If you are running an Ubuntu based distro then run install_ubuntu.sh as root: sudo ./install_ubuntu.sh.\

On other distros you need to install dependencies manually and run build.sh. Dependencies: glew glfw3 cuda ffmpeg libx11 libxcomposite libpulse-simple.
Recording monitors requires a gpu with NvFBC support (note: this is not required when recording a single window!). Normally only tesla and quadro gpus support this, but by using nvidia-patch or nvlax you can do this on all gpus that support nvenc as well (gpus as old as the nvidia 600 series), provided you are not using outdated gpu drivers.

How to use

Run interactive.sh or run gpu-screen-recorder directly, for example: gpu-screen-recorder -w 0x1c00001 -c mp4 -f 60 -a bluez_sink.00_18_09_8A_07_93.a2dp_sink.monitor > test_video.mp4
Then stop the screen recorder with Ctrl+C.
There is also a gui for the gpu-screen-recorder, called gpu-screen-recorder-gtk.

Demo

Click here to watch a demo video on youtube

FAQ

How is this different from using OBS with nvenc?

OBS only uses the gpu for video encoding, but the window image that is encoded is sent from the GPU to the CPU and then back to the GPU. These operations are very slow and causes all of the fps drops when using OBS. OBS only uses the GPU efficiently on Windows 10 and Nvidia.
This gpu-screen-recorder keeps the window image on the GPU and sends it directly to the video encoding unit on the GPU by using CUDA. This means that CPU usage remains at around 0% when using this screen recorder.

How is this different from using FFMPEG with x11grab and nvenc?

FFMPEG only uses the GPU with CUDA when doing transcoding from an input video to an output video, and not when recording the screen when using x11grab. So FFMPEG has the same fps drop issues that OBS has.

TODO

  • Support AMD and Intel, using VAAPI. cuda and vaapi should be loaded at runtime using dlopen instead of linking to those libraries at compile-time.
  • Clean up the code!
  • Fix segfault in debug mode (happens because audio codec becomes NULL?)
  • Dynamically change bitrate/resolution to match desired fps. This would be helpful when streaming for example, where the encode output speed also depends on upload speed to the streaming service.
  • Show cursor when recording. Currently the cursor is not visible when recording a window and it's disabled when recording screen-direct to allow direct nvfbc capture for fullscreen windows, which allows for better performance and variable refresh rate monitors to work.
  • Implement opengl injection to capture texture. This fixes composition issues and (VRR) without having to use NvFBC direct capture.
  • Always use direct capture with NvFBC once the capture issue in mpv fullscreen has been resolved.