How to get that damn screen recording

tl;dr: wf-recorder -et -c h264_vaapi -d /dev/dri/renderD128 -g "$(slurp)" --audio=alsa_output.pci-0000_00_1b.0.output_analog-stereo -f "$HOME/$(date --iso-8601=seconds).mp4"

Say I want to do a screen recording on a desktop using Sway & Pipewire.

It’s difficult. It seems that sway does not support recording single windows, only the entire desktop, even with obs-studio-git installed.

For additional fun I want to record the audio of my desktop, e.g. content from a browser.

So let’s try wf-recorder? That works, but its audio support had a massive snag for me: The -a (or --audio) flags are behaving very particular:

A minimal working example:

$ wf-recorder --audio=alsa_output.pci-0000_00_1b.0.output_analog-stereo
# or
$ wf-recorder -aalsa_output.pci-0000_00_1b.0.output_analog-stereo

The specific audio source string comes from running pactl list sinks | grep Name.

And my final incantation with screen selection and hardware acceleration:

$ wf-recorder -et -c h264_vaapi -d /dev/dri/renderD128 -g "$(slurp)" --audio=alsa_output.pci-0000_00_1b.0.output_analog-stereo -f "$HOME/$(date --iso-8601=seconds).mp4"

This allows me to turn on my laptops monitor, put the window I want to record there, and then select that section of my desktop to record from.

I could not get that to work in obs-studio running on Sway. However, it works really nicely in GNOME when obs-studio is nudged to actually run on Wayland using QT_QPA_PLATFORM=wayland obs.

However, obs-studio seems to use much more resources, so the incantation is still the best way to go for me.

Phew. Happy screen recordings!

Resources: