高性能的 Wlroots 屏幕录制,具有硬件编码功能
High performance screen recorder for wlroots Wayland.
Uses dma-buf transfers to get surface, and uses the GPU to do both the pixel format conversion and the encoding, meaning the raw video data never touches the CPU, leaving it free to run your applications.
Open an issue if something is not working, I'm happy to take a look.
Wayland compositor supporting the following protocols:
vaapi encode support, consult your distribution for how to set this up. Known good configurations:
[^1]: Mesa vaapi (which Radeon GPUs use) does not support transform, so wl-screenrec will not work if you have a monitor that has transform applied to it
(relatively unscientific) benchmark setup:
vkcube running on screen, as both wf-recorder and wl-screenrec don't copy/encode frames when there is no difference| command | CPU Usage | GPU 3D Δ | GPU Video Δ |
|---|---|---|---|
wf-recorder |
~500% | +44% | 0% |
wf-recorder -c h264_vaapi -d /dev/dri/card0 |
~75% | +88% | +23% |
wl-screenrec |
~2.5% | +91% | +30% |
Additionally, with either wf-recorder setup there is visible stuttering in the vkcube window. wl-screenrec does not seem to stutter at all.
However, it does come at the cost of using slightly more GPU. Those number seem stable and I hypothesize that they are statistically significant, but still not a huge change.
paru -S wl-screenrec
# OR
paru -S wl-screenrec-gitOr, manually:
git clone https://aur.archlinux.org/wl-screenrec-git.git
cd wl-screenrec-git
makepkg -siInstall ffmpeg 6 or later, which is a required dependency. ffmpeg 5 may work, but is untested (open an issue or PR if you test with ffmpeg 5 so I can update these docs on if it works or not)
cargo install wl-screenrec # stable version
# OR
cargo install --git https://github.com/russelltg/wl-screenrec # git versionTo install wl-screenrec on Fedora, it's recommended to install it from cargo. Before you do that though, make sure you have the following dependencies installed (you can get them all via DNF):
libdrm-develfreeglut-develclangffmpeg-free-develAlso, make sure you install full ffmpeg and codecs for hardware acceleration support via RPM Fusion.
pkg install wl-screenrecCapture entire output:
wl-screenrec # valid when you only have one output
wl-screenrec -o DP-1 # specify outputCapture region:
wl-screenrec -g "$(slurp)" # use slurp
wl-screenrec -g "0,0 128x128" # manual regionCapture 444 video (no pixel format compression):
NOTE: Look at
vainfo -ato see your supported pixel formats. Support is very hardware-dependent. For example, on my machine only HEVC supports 444 formats, and all of 8-bit RGB formats didn't work for whatever reason.
wl-screenrec --codec hevc --encode-pixfmt vuyx # 8-bit 444
wl-screenrec --codec hevc --encode-pixfmt xrgb10 # 10-bit 444Capture with audio:
wl-screenrec --audio # default capture device
wl-screenrec --audio --audio-device alsa_output.pci-0000_00_1f.3.hdmi-stereo.monitor # capture desktop audio (example, use `pactl list short sources` to figure out what you should put here)Record with history:
wl-screenrec --history 10 & # record the most recent 10 seconds into memory, not writing into the file
# ... some important event occurs
killall -USR1 wl-screenrec # flush the most recent 10 seconds onto the file, and start appending to the file like recording normallyCapture to v4l2loopback (for Zoom, etc):
sudo modprobe v4l2loopback
v4l2-ctl --list-devices # find "Dummy video device" device. /dev/video6 in my case.
wl-screenrec --ffmpeg-muxer v4l2 -f /dev/video6…暂无开放 Issues,或尚未同步最近议题。