With the new Raspberry Pi models available, video capture and streaming become possible.
Even if we are still far from a professional computer, the Raspberry Pi 4 can handle this pretty well.
One of the most used software for video capture on PC is OBS Studio, and it is possible to install it on Raspberry Pi. Let’s see how.
OBS Studio is a free software for streaming and video recording.
On Raspberry Pi, the installation can be done by building the source available on the GitHub project.
After that, OBS Studio is available in the main menu.
As there is no package available, I will guide you through the installation process, and show you how to use it once installed.
But before that, we will start by a quick overview about OBS Studio.
Introduction to OBS Studio
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!
What is OBS Studio?
OBS Studio is one of those tool you can use to record a video on your computer.
The good news is that it’s a free and powerful tool to do this.
You can manage multiple sources (like a Camera module or a USB device), and include several of them in a recording.
OBS Studio is also often use for live-streaming, as you can manage everything in real time in a drag and drop preview.
OBS Studio on Raspberry Pi
OBS Studio is available for any operating system.
You can find binaries for Windows and macOS on the home page, and it’s available in the default repositories in most Linux distributions.
Currently, the Raspberry Pi is not officially supported, but you can download the sources and compile them on it.
As I use OBS Studio on my computer to record my YouTube videos, I was curious to see how it works on Raspberry Pi OS.
For example, I have some issues recording my screen on Raspberry Pi 4, the stream quality I receive on my video capture device is not as good as on Raspberry Pi 3B+ (probably due to the micro HDMI port or at least the adapter).
So, it can be a good alternative to record it directly on the Raspberry Pi.
Install OBS Studio
OBS Studio is not optimized for Raspberry Pi, there is no release for it and no specific development for the ARM architecture.
The compilation process can be very long depending on your Raspberry Pi model. I even crash my Raspberry Pi 3B+ several times without succeeding.
So, I really recommend a Raspberry Pi 4 4 GB or 8 GB on Amazon to follow this tutorial.
If you want to try on Raspberry Pi 3B+, it could work if you create a swap file (I didn’t have one in my tests on Pi 4).
Here is how to create it (in a terminal or via SSH):
sudo dd if=/dev/zero of=/var/swap2 bs=1024 count=1000000
sudo chmod 600 /var/swap2
sudo mkswap /var/swap2
sudo swapon /var/swap2
Even with a Raspberry Pi 4, the compilation will use 100% of your CPU and a big part of the memory. So be patient if you try on another device.
Once the system ready, you need to install a huge list of packages before starting the compilation.
Here is the command to copy and paste in a terminal:
sudo apt install build-essential checkinstall cmake git libmbedtls-dev libasound2-dev libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libcurl4-openssl-dev libfontconfig1-dev libfreetype6-dev libgl1-mesa-dev libjack-jackd2-dev libjansson-dev libluajit-5.1-dev libpulse-dev libqt5x11extras5-dev libspeexdsp-dev libswresample-dev libswscale-dev libudev-dev libv4l-dev libvlc-dev libx11-dev libx11-xcb1 libx11-xcb-dev libxcb-xinput0 libxcb-xinput-dev libxcb-randr0 libxcb-randr0-dev libxcb-xfixes0 libxcb-xfixes0-dev libx264-dev libxcb-shm0-dev libxcb-xinerama0-dev libxcomposite-dev libxinerama-dev pkg-config python3-dev qtbase5-dev libqt5svg5-dev swig libwayland-dev qtbase5-private-dev libpci-dev
Another prerequisite is the FDK AAC package. FDK AAC is the FFmpeg encoder for the AAC format
It’s the successor from MP3, often use in MP4 streams, and required for OBS Studio.
The installation is slightly different depending on whether you are using Bullseye or not.
Raspberry Pi OS Bullseye
On Bullseye, you can install it easily with:
sudo apt install libfdk-aac2 libfdk-aac-dev
Raspberry Pi OS Buster (Legacy)
On Raspberry Pi OS Buster, it’s not available in the default repository, so we will download it from the Debian repository and install it manually. Here is how to install it on Raspberry Pi OS Legacy / Buster:
- Download these two files:
- Install them with:
sudo dpkg -i libfdk-aac2_2.0.1-1_armhf.deb
sudo dpkg -i libfdk-aac-dev_2.0.1-1_armhf.deb
You are now ready to download and compile the source code
Build the source code
As I told you in introduction, we will download the source code from the GitHub project.
Follow these steps to download and install everything:
- Download the source code with git:
sudo git clone --recursive https://github.com/obsproject/obs-studio.git
You can move to a specific folder if you want (like /opt), personally I have done this in the Downloads folder.
- Move to the new folder:
- Create a build folder and move into this one:
sudo mkdir build
- Run cmake
sudo cmake -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_PIPEWIRE=OFF -DBUILD_BROWSER=OFF ..
- And finally start the compilation:
sudo make -j4
The compilation time depends on your hardware, between a few minutes and one hour probably 🙂
- And here is the last step is to install OBS Studio:
sudo make install
That’s it, OBS is now ready to use
Once installed, you can start it from the main menu:
Sound & Video > OBS Studio
On the first run, an auto-configuration wizard is available to set the default settings.
I recommend using it so you don’t have anything else to change to get started.
Answer the few questions (you can keep the default values if you have no idea) and OBS will run a test to configure everything. Click on “Apply settings to confirm”.
If it doesn’t work as expected, try to run OBS Studio from a terminal, and see if you get one of the following errors.
On Raspberry Pi 4 (at least), you can’t run it directly.
I had this error:
"Failed to initialize video. Your GPU may not be supported, or your graphic drivers may need to be updated"
Let me know if you have another solution, but the only thing that worked for me is to set this variable before starting obs:
- Open a terminal
- Run this command:
This should work as expected now, you can run the auto-configuration wizard like explained in the previous step.
On the latest versions of Raspberry Pi OS, you may also get a Segmentation fault:
info: OBS 27.2.0-246-gf695b14ed (linux)
info: audio settings reset:
samples per sec: 48000
info: Initializing OpenGL…
You can fix by adding the path to libGl.so in prefix to the command line, for example:
LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libGL.so obsOr if you have the previous error too:
LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libGL.so MESA_GL_VERSION_OVERRIDE=3.3 obs
Use this command to get the exact path for your system:
OBS Studio tips on Raspberry Pi
Once OBS started, the difficult part is done, you will find any help you need on specialized websites and forum.
But, just to help you to take a good start, I will show you how to capture your screen or camera.
Here is how to capture your screen with OBS:
- By default, the “Sources” panel is available at the bottom of the screen
- Click on “+” to add a source
- Choose “Screen Capture (XHSM)”
- A window shows up asking for a source name.
Keep it by default or enter whatever you want.
Then confirm with OK.
- On the next screen, you can confirm a few things like the screen to capture (on a Raspberry Pi 4 with two screens only), if you want to capture the mouse pointer and another advanced setting (X server)
- From here, your screen appears on the default scene
Sale: 10% off today.
Get the eBook.
Do more with your Raspberry Pi, learn the useful concepts and take the shortcuts.
You miss half of the fun of using a Raspberry Pi if you don’t know anything about Python.
It will be easier with two screens (one with OBS and the other with the things you want to record), but it works in any case.
If you have a camera (Pi module or other), you can add it to the sources almost the same way:
- Enable your camera on Raspberry Pi OS (click the link for more details)
- Click on “+” in the “Sources” panel
- Choose “Video Capture Device (V4L2)” as new source
- Again, choose a name and confirm
- In the next window, you can configure everything about your camera
For example, mine needed a rotation to display the image in the correct orientation, so I just changed the “Rotation” value and let the other settings by default
- Confirm to add it in the source list
Once you have at least one source, you change the image size on the screen
For example, you can use OBS to stream your desktop and use your camera to show your face in a corner.
All the settings can be change by click on the “Settings” button on the right (general, stream to Twitch, output quality and format, shortcuts, etc.)
OBS also manage other sources the same way (audio for example)
To record your screen or camera, type “Start Recording” on the right.
The default output folder is /home/pi, files are in MKV with a 1080p high quality.
You can change everything in the settings.
By default, there is no shortcut so you need to use a mouse to start/stop a record or anything else.
In the settings it’s possible to set a shortcut to each action.
Reminder: Remember that all my Patreon supporters get access to this website without ads, early access to my videos and much more. You can become part of this community for as little as $3 per month & get all the benefits immediately.
Grab your free PDF file with all the commands you need to know on Raspberry Pi!
That’s it! You now know how to install and configure OBS on your Raspberry Pi.
I tested on Raspberry Pi 4, it works pretty well (except the menu icon)
No lag, no bug, so it’s good news.
I’ll probably try it in a future video for the YouTube channel and let you know if I have anything else to add.