This page looks best with JavaScript enabled

Screen recording on FreeBSD

 ·  🎃 kr0m

FreeBSD offers different audio/video capture tools with their pros and cons. Depending on our needs, we will choose one or the other:


Simple Screen Recorder

The easiest tool to use for screen recording is simplescreenrecorder. It allows us to record the entire screen, an area of it, or a window of a particular application.

pkg install simplescreenrecorder

The problem with simplescreenrecorder is that it only allows recording from pulseaudio and jack devices. I have not been able to make it work with either system, so I use it when I only want to record video.


Virtual OSS

It seems that by default, OSS does not allow the audio output to be the input of another application. To do this, we will have to create a new device using virtual_oss.

pkg install virtual_oss

We load the cuse module:

kldload cuse
sysrc cuse_load=YES

We allow our regular user to execute virtual_oss as root:

vi /usr/local/etc/sudoers.d/kr0m

kr0m ALL=(ALL) NOPASSWD: /usr/local/sbin/virtual_oss

We duplicate the /dev/dsp4 device (default audio output on my system) into /dev/dsp.virtual_oss.

sudo virtual_oss -S -C 2 -c 2 -r 44100 -b 16 -s 1024 -f /dev/dsp4 -d dsp -w dsp.virtual_oss.wav -l dsp.virtual_oss -t /dev/dsp.virtual_oss.ctl

Now applications that record from /dev/dsp.virtual_oss will be recording the audio output that we hear.


OBS

OBS: Open Broadcaster Software is one of the most complete software for streaming and video recording. It allows us to add both video and audio sources. To record the audio, we must first create the device using virtual_oss and add it as shown below.


FFMPEG

The advantage of ffmpeg is that it is usually installed on almost all desktop computers, allowing us to make recordings without the need to add additional software. To record the audio, we must first create the device using virtual_oss.

To start a recording, it is as simple as running the following command:

sleep 3 && notify-send “Recording” && ffmpeg -f x11grab -thread_queue_size 1024 -s xdpyinfo | grep -i dimensions: | sed 's/[^0-9]*pixels.*(.*).*//' | sed 's/[^0-9x]*//' -r 25 -i :0.0 -f oss -thread_queue_size 1024 -i /dev/dsp.virtual_oss recording.mp4

If you liked the article, you can treat me to a RedBull here