Stockton Web & Cloud Services Company Articles Let's Talk 801-360-8331
We are an 🇺🇸American🇺🇸 small business! Help us grow! Share with a friend. We have fast response times and very reasonable prices.
Vultr Cloud for your next cloud project!
Recording the Desktop, Camera, and Mic, in OpenBSD

Recording the Desktop, Camera, and Mic, in OpenBSD

I've been needing to start recording some videos again, and I wanted to make sure to do so without having to go back to Linux or macOS. So I looked up the intricacies of how I might do this using OpenBSD, as that is what I currently have on my laptop.

I've been quite happy with OpenBSD overall. It's not very complicated to use, and the suspend/resume works really well.

I still need to really test out what I've posted here, and see how smooth this is going to be, and if the audio will be in sync. The last time I was trying this I had troubles with the voice audio being in sync. So there may be some other settings to add, but this is a good starting point.

This laptop model is Lenovo T460s. I am using a Logitech HD Pro Webcam C920. The camera also has a microphone.

Before being able to record, you must enable audio and video recording.

doas sysctl kern.video.record=1
doas sysctl kern.audio.record=1

I am also wanting to record by using my normal system user, so I am changing the video devices ownership to my user:

doas chown jon /dev/video0
doas chown jon /dev/video1

When I'm done, I just change them back. I have scripts to do this:

# Disable recording once more.
sysctl kern.video.record=0
sysctl kern.audio.record=0
chown root /dev/video0
chown root /dev/video1

Once I am ready to record, I run this script:

ffmpeg \
        -f sndio \
        -thread_queue_size 4096 \
        -i snd/1 \
        -video_size 1920x1080 \
        -f x11grab -i :0 \
        -f video4linux2 \
        -video_size 640x480 \
        -thread_queue_size 4096 \
        -i /dev/video1 \
        -filter_complex "overlay=main_w-overlay_w-5:main_h-overlay_h-5" \
        -c:v libx264 \
        -preset ultrafast \
        -crf 18 \
        output.mp4

The first section gets the audio, then the screen, then the camera. Then the "filter_complex" puts the video overlayed, and in the bottom right corner.

Share X.com Truth Social

Written by Jon

Author Profile Picture

Hi, I'm Jon. I live in Utah with my awesome wife and children, where we enjoy hockey, basketball, soccer, and raising chickens! I have a bachelors degree in Software Development, various computer & project management certifications, and I've worked for web hosting and other dev/online companies for over a decade.