Making screencasts on the Raspberry Pi 5 and Raspberry Pi OS Bookworm

November 14th, 2023

Recording your desktop, or recording a part of your desktop, or piping your desktop to Zoom, or in general as a webcam input, it can all be done quite easily with the new Raspberry Pi 5.

The new version of Debian is using Wayland as a default, so it’s always a bit of a search how to do rather trivial things on a new device and a new environment.

Anyhow there is a versatile simple Wayland desktop recording program, wf-recorder, that can be installed with:

sudo apt install wf-recorder

You can find more info here:

Recording is a simple as running wf-recorder 🙂

That outputs a file recording.mp4 in the directory it’s run from, so to get it organized a bit it needs some cli parameters.

Furthermore the programs starts recording until you kill it, normally by CTRL C on the cli.

Let’s setup a keyboard shortcut that records the desktop and save it in the Video’s folder with a filename screencast-2023-11-14_12-20.mkv, so it’s includes date and time.

And because the Raspberry Pi 5 can drive two monitors you have to specify which screen the screencast should be made of.

So to add shortcuts to the Wayland environment, just open .config/wayfire.ini and add them there:

binding_screencast_hdmi_a_1 = <super> <ctrl> KEY_1
command_screencast_hdmi_a_1 = timeout 30s wf-recorder -p crf=28 -t -o HDMI-A-1 -f "/home/pi/Videos/screencast-$(date +%Y-%m-%d_%H-%M).mkv"
binding_screencast_hdmi_a_2 = <super> <ctrl> KEY_2
command_screencast_hdmi_a_2 = timeout 30s wf-recorder -p crf=28 -t -o HDMI-A-2 -f "/home/pi/Videos/screencast-$(date +%Y-%m-%d_%H-%M).mkv"
binding_screencast_hdmi_a_1_audio = <super> <alt> KEY_1
command_screencast_hdmi_a_1_audio = timeout 30s wf-recorder -a -p crf=28 -t -o HDMI-A-1 -f "/home/pi/Videos/screencast-$(date +%Y-%m-%d_%H-%M).mkv"
binding_screencast_hdmi_a_2_audio = <super> <alt> KEY_2
command_screencast_hdmi_a_2_audio = timeout 30s wf-recorder -a -p crf=28 -t -o HDMI-A-2 -f "/home/pi/Videos/screencast-$(date +%Y-%m-%d_%H-%M).mkv"

On the first line we define the shortcut, on the second line the command that should be executed.

I have setup 4 shortcuts to:

  1. record screen 1 by pressing SUPER + CTRL + 1
  2. record screen 1 with audio  by pressing SUPER + ALT + 1
  3. record screen 2 by pressing SUPER + CTRL + 2
  4. record screen 2 with audio by pressing SUPER + ALT + 2

Of course you can change the shortcuts to your liking.

I choose to record just 30 sec, it will stop automatically. In Linux you can do that simple with timeout 30s command

The moment I’m typing this blog-post, I realize it is probably better to add another 5th shortcut to kill/stop the recording, so you could make recordings with variable duration.

Well not that difficult, just bind a shortcut to

killall -s SIGINT wf-recorder

And remove the `timeout 30s` part.

wf-recorder only records screen updates by default, so recording a static desktop will output an empty file 😉 Nothing to record when nothing is happening, saving MB’s on file size. Add -D to record every frame.


Leave a Reply