Skip to content
Scott Moreau edited this page Jul 31, 2022 · 12 revisions

Basics

The purpose of wf-recorder is to create a video file by recording your desktop. To use it, install and run it with

wf-recorder

It will output some text and begin recording. Use Ctrl+C to stop recording. The video file will be stored as recording.mp4 in the current working directory.

Audio

To tell wf-recorder to record audio, use -a

wf-recorder -a

Check pavucontrol recording tab for an entry while it is recording and choose the input. Optionally pass --audio=<device> where <device> is one output by pactl list sources | grep Name.

Hardware acceleration

wf-recorder -c h264_vaapi -d /dev/dri/renderD128 -f out.mp4

Optionally change the encoder codec to one found with ffmpeg -encoders|grep vaapi, provided vainfo shows the driver supports it.

Recording both mic input and application sounds

Note that by default, either mic input or monitor of speakers can be used for input but not both. You can work around this by running pactl load-module module-loopback to load the loopback module, which outputs the mic to the default speaker output, however it might not work very well depending on your exact setup.

A better, but more complicated way: Run pactl list sources | grep Name and note the names of all the sources that you want to capture. Now, create a virtual sink, then using the loopback module make each of the sources output to this sink, and finally capture the sink's monitor with wf-recorder (replace the alsa_* are the names of the sources to capture)

pactl load-module module-null-sink sink_name=Combined
pactl load-module module-loopback sink=Combined source=alsa_output.pci-0000_00_1f.3.analog-stereo.monitor
pactl load-module module-loopback sink=Combined source=alsa_input.pci-0000_00_1f.3.analog-stereo 

Now use Combined.monitor as source for wf-recorder.

Using wf-recorder as camera

You can use wf-recorder and v4l2loopback to display your monitor as a camera in Zoom & other applications.

Basic setup:

  1. Install v4l2loopback kernel module as described in its repository, then load it with
sudo modprobe v4l2loopback exclusive_caps=1 card_label=WfRecorder
  1. Launch wf-recorder with the following parameters:
wf-recorder --muxer=v4l2 --codec=rawvideo --file=/dev/video2 -x yuv420p

You may need to adjust the file name, for ex. set it to /dev/video0 depending on how many cameras are already existing on your computer.

NOTE: The intel driver does rgb0 to yuv420 conversion implicitly while gallium drivers like radeon and nouveau do not. Depending on the case, it might be useful to do the conversion on the gpu by using vaapi with the following command:

wf-recorder -f /dev/video2 --muxer=v4l2 -d /dev/dri/renderD128 --codec=h264_vaapi --pixel-format=yuv420p
  1. Test the camera with ffplay, cheese or any webcam test in your browser.
ffplay /dev/video2

(Instructions based on https://github.com/ammen99/wf-recorder/pull/43)

Native webcam

Use the following command to show /dev/video0 in a native window with gst-launch-1.0 (gstreamer). Note that glimagesink must be available.

gst-launch-1.0 -v v4l2src device=/dev/video0 ! glimagesink