Question / Help OBS Raspberry Pi Build Instructions

TheMindVirus

New Member
It is possible to build OBS Studio for Linux from source on the Raspberry Pi 3 upwards!

Disclaimer: Please make sure you understand what this code does first,
then you may run it at your own risk. As versions change, problems may arise.
The scripts take a long time, especially on underpowered hardware and slow internet.


The pi has very limited memory, so it is essential to make a swapfile first:
Code:
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
sudo swapon
Here is an automated script that downloads, builds and installs OBS on the pi:
Code:
#!/bin/bash
#File: installobs.sh (sudo chmod +x installobs.sh)
#!!! Please run from /home/pi/Downloads (cd /home/pi/Downloads)

sudo apt-get --allow-releaseinfo-change update
sudo DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
sudo apt-get -y 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
sudo wget http://ftp.uk.debian.org/debian/pool/non-free/f/fdk-aac/libfdk-aac1_0.1.4-2+b1_armhf.deb
sudo wget http://ftp.uk.debian.org/debian/pool/non-free/f/fdk-aac/libfdk-aac-dev_0.1.4-2+b1_armhf.deb
sudo dpkg -i libfdk-aac1_0.1.4-2+b1_armhf.deb
sudo dpkg -i libfdk-aac-dev_0.1.4-2+b1_armhf.deb
sudo git clone --recursive https://github.com/obsproject/obs-studio.git
cd obs-studio
sudo mkdir build && cd build
sudo cmake -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr ..
sudo make -j4
sudo make install
obs #only need to run this command from now on

exit 0
Hope you find this useful!
 

TheMindVirus

New Member
The build is a little temperamental at the moment. I've had it running once and it displayed the window correctly with the normal features available. Sometimes however it fails to start with a GPU Framebuffer Error. I will try different builds and also on a Raspberry Pi 4 to see if it performs any better.
 

TheMindVirus

New Member
This is it running on a Raspberry Pi 3 Model A with a SanDisk 128GB SD Card on a new Raspbian Image.
I tried exactly the same thing on my older images on smaller SD cards and it hit problems while building.
 

Attachments

TheMindVirus

New Member
For Raspberry Pi 4 users, it seems that Raspbian Buster for some reason wants to use OpenGL Version 1.4.
OBS will fail to create an OpenGL context on this version and won't start.
To force Raspbian to use OpenGL Version 3.3, run OBS from the terminal like this:
Code:
MESA_GL_VERSION_OVERRIDE=3.3 obs
 

dodgepong

Administrator
Forum Admin
ARM usage isn't very popular for OBS, and as such I don't think anyone has asked us to implement VideoCore encoder support yet. I didn't even know it was a thing until this post.
 

TheMindVirus

New Member
The OBS dev team shouldn’t have had to do any additional work or even know that the VideoCore existed because it should have been abstracted by OpenGL.

That said, direct encoder support for ARM devices would open up some new and very interesting doorways for this project and others in the mobile world.
 

dodgepong

Administrator
Forum Admin
The OBS dev team shouldn’t have had to do any additional work or even know that the VideoCore existed because it should have been abstracted by OpenGL.
Not sure I follow, here. OBS uses x264 for software encoding. It uses OpenGL for rendering, but I can't see how the RPi would automatically know to use a different encoder than the one it was programmed to use just because it's using OpenGL to render.
 

TheMindVirus

New Member
It’s a feature that modern day graphics platforms should have the ability to abstract, enumerating available encoders (perhaps even requesting them). Since it doesn’t currently work like that, we are left in a situation where OBS runs on new hardware but is unable to make the most of it.
 

TheMindVirus

New Member
I'm glad you got it working. For that plugin it should be largely the same process using cmake from the source code. I'll take a look...
 

TheMindVirus

New Member
Whilst I could write some overcomplicated instructions on how to build spotify libcef, chromium and then obs-linuxbrowser,
it would probably be easier to just use the Window Capture (XComposite) media source and crop out the window frame.
You can even grab the taskbar, that's unique. Not seen that before.
 

nmaas87

New Member
Yes, I guess that could work in many use-cases. However, I try to build a streaming box which works "out-of-the-box" with possible no user interaction, just adding the analog / composite video to the card, power and network. I used the browser plugin in my test-Windows 10-machine to add time-information to the video as an overlay and i am glad that it works there / directly in OBS - I am afraid that starting i.e. chromium externally with the javascript file for the time overlay could at some point in time break, i.e. if a browser window is incorrectly cropped, another tab is opened do to a new update installed etc etc and the XComposite losing focus or not being able to accquire a correct snapshots of the target browser window due to rescaling or similar. So I would humbly prefer, if possible, to solve it with the plugin and not XComposite.
 

dodgepong

Administrator
Forum Admin
It's worth noting that the official browser source was finally integrated into the master build of OBS. You shouldn't need obs-linuxbrowser anymore, though if you're building it yourself you will still need CEF.
 

nmaas87

New Member
@dodgepong Thats an excellent hint. I would also use the official browser of OBS - however, I could not find it. I did compile it yesterday morning according to @TheMindVirus instructions, however, after starting OBS, no browser plugin was visible in the sources section.
How to enable it / or something else needed?

Thank you very much!
 

TheMindVirus

New Member

nmaas87

New Member
Thank you two!
Yeah I tried the road with the obs-qtwebkit.

Bash:
sudo apt install libqt5webkit5-dev qtbase5-dev
cd ~/Downloads
git clone https://github.com/bazukas/obs-qtwebkit.git
cd obs-qtwebkit
make
however, this brings up an error / incompability with xmmintrin.h (which seems to be a x86/x64 compability layer?!) which seems to cannot be compiled on ARM - but I might be wrong here.

Code:
g++ -c -std=c++11 -Wall -g -fPIC -I/usr/include/obs -I./src -I/usr/include/arm-linux-gnueabihf/qt5/QtWebKitWidgets src/qtwebkit-main.cpp -o build/qtwebkit-main.o
In file included from /usr/include/obs/graphics/vec4.h:22,
                 from /usr/include/obs/graphics/vec3.h:21,
                 from /usr/include/obs/obs.h:26,
                 from /usr/include/obs/obs-module.h:20,
                 from src/qtwebkit-main.cpp:21:
/usr/include/obs/graphics/../util/sse-intrin.h:63:10: fatal error: xmmintrin.h: No such file or directory
 #include <xmmintrin.h>
          ^~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:55: build/qtwebkit-main.o] Error 1
Also, obs-qtwebkit might be flagged as an substitute to the cef based browser plugin (and seemed to have worked in the past :)) - however, it has been abandoned and archived on github - so there is actually no real support anymore.

But I would be more than happy if I could get it working somehow as I guess it would be easier to get it compiled with qt than cef? (At least that it was I hope, but I might be wrong again here - so sorry if I am messing up :/!)

Any ideas to go forward? I have been googling a bit but have not yet discovered something useful (but I will try :))

Best regards
 

cold_matt

New Member
I'm glad you got it working. For that plugin it should be largely the same process using cmake from the source code. I'll take a look...

Hi MindVirus, thanks a lot for this script. It works on my Pi 4 just fine when I run OBS from the terminal with the GL version override.

One unforeseen consequence which I think has resulted from this is that my Alesis Core 1 audio interface is now no longer properly recognised by the pi. It appears in the list of audio inputs and outputs, but I can no longer adjust the volume in software the way I did before, and when using it to make recordings (e.g. in audacity) the sound is either not there or is hugely distorted. As a result, I currently can't use OBS as I had hoped: to get sound from an external mixer and video from a USB webcam.

I'm wondering if maybe some of those sound library/codec installs in the bash script have overwritten something unfortunate?
 
Top