Hands-off recording of webinars on Linux with Xephyr, Pulseaudio and OBS

The open-source screen recording tool OBS simplifies capturing, encoding and streaming audio & video. In particular, through the XSHM and/or XComposite extensions, OBS can capture whatever is currently showed on your screen. This allows one to rather easily record webinars and other live audiovisual events for later reference.

One drawback of such screen-capture recording is that the user cannot use the computer during recording: all other data shown on screen or piped through the speakers would show up in the recording, thereby occluding the thing one wanted to capture.

For audio, a workaround is to use pulseaudio to send the audio stream of the event to be recorded to an extra ‘dummy’ sink, and select that sink for recording in OBS. To enable this, my ~/.config/pulse/default.pa contains the line load-module module-null-sink sink_name=null_sink sink_properties=device.description=Passthrough_null_sink, which adds an extra option Passthrough_null_sink to the selection options in pavucontrol so that I can selectively pipe audio to this separate output. In OBS, this corresponds to an Audio output capture (Pulseaudio) source set to the Passthrough_null_sink device.

For video, the most effective solution I have come across is to view the webinar in a separate X server. As running multiple standalone X servers tends to be problematic, I have settled on running Xephyr to embed a second X server as a window in the main X server. That is, when I want to record a webinar while retaining full usage of my computer, I start a Xephyr instance with

startx ~/.xsession2 -- /usr/bin/Xephyr -br -ac -noreset -screen 1600x900 :1

where the ~/.xsession2 file, used to bootstrap the applications run in Xephyr, reads

i3 &
chromium --temp-profile &
/home/abel/build/xclipsync/xclipsync &
wait %1

Here, i3 is my main window manager - used here to manage the windows inside Xephyr, chromium --temp-profile tells my browser to start a temporary instance (separate from any instances I may be interacting with in the main X server) and xclipsync is a small script used to synchronize the clipboards between Xephyr and X.

Now, I can simply record everything happening inside the Xephyr window by adding a Screen capture (XSHM) video feed to OBS and adding :1 to the X Server field that appears when checking Advanced Settings.