Eric Radman : a Journal

Screencasting with OpenBSD

Notes on making a screen capture.

Audio Input

USB microphone appear as an audio device

uaudio0 at uhub0 port 2 configuration 1 interface 0 "M-One USB" rev 1.10/0.01 addr 2
uaudio0: audio rev 1.00, 8 mixer controls
audio1 at uaudio0

audioctl can read off all of the specific characteristics of this device

$ audioctl -f /dev/audio1 | grep record
mode=play,record
record.rate=48000
record.channels=1
record.precision=16
record.bps=2
record.msb=1
record.encoding=slinear_le
record.pause=0
record.active=0
record.block_size=1960
record.bytes=0
record.errors=0

Test the recording from the second audio device using aucat

aucat -f snd/1 -o file.wav

If the device also has a headset audio can be played through the same device.

aucat -f snd/1 -i file.wav

Audio Adjustment and Trimming

To trim the beginning and end of the recording specify the start time and duration using the encoding option copy

ffmpeg -i interactive-sql.avi -vcodec copy -acodec copy \
    -ss 00:00:00 -t 00:09:45 interactive-sql-trimmed.avi

normalize is a quick method of adjusting audio for an entire stream.

ffmpeg -i interactive-sql.avi -c:a copy -vn audio.wav
normalize audio.wav

Next merge the audio back in again

ffmpeg -i interactive-sql.avi -i audio.wav \
    -map 0:0 -map 1:0 -c copy interactive-sql-normalized.avi

Video Transcoding

VP8/VP9

ffmpeg -i interactive-sql-normalized.avi -c:v libvpx -b:v 1M \
    -c:a libvorbis -q:a 6 interactive-sql.webm

h264

ffmpeg -i interactive-sql-normalized.avi -c:v libx264 \
    -preset slow -crf 14 -movflags +faststart \
    -c:a aac -q:a 6 interactive-sql.mp4

-movflags puts the index data at the beginning of the file to enable streaming/partial content requests over HTTP.

Copying a Video Stream

On OpenBSD, ensure recording is permitted in /etc/sysctl.conf

kern.audio.record=1
kern.video.record=1

And monitor additional audio inputs in /etc/rc.conf.local

sndiod_flags="-f rsnd/0 -f rsnd/1"

Using a HDMI-USB capture device, high-fidelity video can be captured from any source

uvideo2 at uhub1 port 14 configuration 1 interface 0 "Magewell USB Capture HDMI" rev 3.00/20.41 addr 9
video2 at uvideo2
uaudio0 at uhub1 port 14 configuration 1 interface 3 "Magewell USB Capture HDMI" rev 3.00/20.41 addr 9
uaudio0: class v1, high-speed, sync, channels: 0 play, 2 rec, 3 ctls
audio1 at uaudio0

On the playback machine mirror output

xrandr --output HDMI-1 --auto
xrandr --output HDMI-1 --same-as eDP-1

Switch audio output to HDMI for playback. Framerate needs to specified if the capture device is capable of 60fps

ffmpeg -f v4l2 -r 30 -video_size 1920x1080 -i /dev/video2 -f sndio -i snd/1 recording.mkv

Raw audio capture

 ffmpeg -vn -f sndio -i snd/1 -c:a copy recording.wav
 normalize recording.wav