Skip to content

Instantly share code, notes, and snippets.

@shivasiddharth
Last active January 24, 2023 04:46
Show Gist options
  • Save shivasiddharth/b6756dda4a0bc97ff5a0f3854eec668a to your computer and use it in GitHub Desktop.
Save shivasiddharth/b6756dda4a0bc97ff5a0f3854eec668a to your computer and use it in GitHub Desktop.
Script for installing OBS on Raspberry Pi
#!/bin/bash
echo ""
echo "Checking memory size.........."
Totalmem=$(cat /proc/meminfo|grep MemTotal|grep -o '[0-9]*')
if (($Totalmem > 3500000)); then
echo ""
echo "You have got enough memory. No need for a swap partition.........."
echo ""
else
echo ""
echo "Creating swap partition.........."
echo ""
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
fi
echo ""
echo "Compiling FFMPEG.........."
echo ""
sudo apt-get -y install autoconf automake build-essential cmake doxygen git graphviz imagemagick libasound2-dev libass-dev libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libfreetype6-dev libgmp-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libopus-dev librtmp-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev libsnappy-dev libsoxr-dev libssh-dev libssl-dev libtool libv4l-dev libva-dev libvdpau-dev libvo-amrwbenc-dev libvorbis-dev libwebp-dev libx264-dev libx265-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-xfixes0-dev libxcb1-dev libxml2-dev lzma-dev meson nasm pkg-config python3-dev python3-pip texinfo wget yasm zlib1g-dev libdrm-dev
cd /home/pi/
mkdir ~/ffmpeg-libraries
git clone --depth 1 https://github.com/mstorsjo/fdk-aac.git ~/ffmpeg-libraries/fdk-aac \
&& cd ~/ffmpeg-libraries/fdk-aac \
&& autoreconf -fiv \
&& ./configure \
&& make -j$(nproc) \
&& sudo make install
git clone --depth 1 https://code.videolan.org/videolan/dav1d.git ~/ffmpeg-libraries/dav1d \
&& mkdir ~/ffmpeg-libraries/dav1d/build \
&& cd ~/ffmpeg-libraries/dav1d/build \
&& meson .. \
&& ninja \
&& sudo ninja install
git clone --depth 1 https://github.com/ultravideo/kvazaar.git ~/ffmpeg-libraries/kvazaar \
&& cd ~/ffmpeg-libraries/kvazaar \
&& ./autogen.sh \
&& ./configure \
&& make -j$(nproc) \
&& sudo make install
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx ~/ffmpeg-libraries/libvpx \
&& cd ~/ffmpeg-libraries/libvpx \
&& ./configure --disable-examples --disable-tools --disable-unit_tests --disable-docs \
&& make -j$(nproc) \
&& sudo make install
git clone --depth 1 https://aomedia.googlesource.com/aom ~/ffmpeg-libraries/aom \
&& mkdir ~/ffmpeg-libraries/aom/aom_build \
&& cd ~/ffmpeg-libraries/aom/aom_build \
&& cmake -G "Unix Makefiles" AOM_SRC -DENABLE_NASM=on -DPYTHON_EXECUTABLE="$(which python3)" -DCMAKE_C_FLAGS="-mfpu=vfp -mfloat-abi=hard" .. \
&& sed -i 's/ENABLE_NEON:BOOL=ON/ENABLE_NEON:BOOL=OFF/' CMakeCache.txt \
&& make -j$(nproc) \
&& sudo make install
git clone https://github.com/sekrit-twc/zimg.git ~/ffmpeg-libraries/zimg \
&& cd ~/ffmpeg-libraries/zimg \
&& sh autogen.sh \
&& ./configure \
&& make \
&& sudo make install
sudo ldconfig
wget -P ~/ffmpeg-libraries/ https://github.com/FFmpeg/FFmpeg/archive/n4.3.tar.gz
tar -xf ~/ffmpeg-libraries/n4.3.tar.gz -C ~/ffmpeg-libraries/
mv ~/ffmpeg-libraries/FFmpeg-n4.3/ ~/ffmpeg-libraries/FFmpeg/
sudo rm /home/pi/ffmpeg-libraries/n4.3.tar.gz
cd ~/ffmpeg-libraries/FFmpeg \
&& ./configure \
--extra-cflags="-I/usr/local/include" \
--extra-ldflags="-L/usr/local/lib" \
--extra-libs="-lpthread -lm" \
--arch=armel \
--enable-gmp \
--enable-gpl \
--enable-libaom \
--enable-libass \
--enable-libdav1d \
--enable-libdrm \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libkvazaar \
--enable-libmp3lame \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-libopus \
--enable-librtmp \
--enable-libsnappy \
--enable-libsoxr \
--enable-libssh \
--enable-libvorbis \
--enable-libvpx \
--enable-libzimg \
--enable-libwebp \
--enable-libx264 \
--enable-libx265 \
--enable-libxml2 \
--enable-mmal \
--enable-nonfree \
--enable-omx \
--enable-omx-rpi \
--enable-version3 \
--target-os=linux \
--enable-pthreads \
--enable-openssl \
--enable-hardcoded-tables \
&& make -j$(nproc) \
&& sudo make install
echo ""
echo "Installing OBS.........."
echo ""
sudo apt-get update
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/shivasiddharth/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
echo ""
echo "All done.........."
exit 0
@jhamilt0n
Copy link

jhamilt0n commented Jul 22, 2020

I am getting the following error:
mkdir: cannot create directory ‘build’: File exists
CMake Error: The source directory "/home/pi/ffmpeg-libraries/FFmpeg" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
make: *** No targets specified and no makefile found. Stop.
make: *** No rule to make target 'install'. Stop.

All done..........

Any ideas on how to resolve this?

Update: Attempted again and am now getting:
CMake Error at CMakeLists.txt:62 (include):
include could not find load file:

ObsHelpers

CMake Error at CMakeLists.txt:63 (include):
include could not find load file:

ObsCpack

-- No Native SSE2 SIMD Support - Using SIMDE
CMake Error at CMakeLists.txt:236 (add_subdirectory):
add_subdirectory given source "deps" which is not an existing directory.

CMake Error at CMakeLists.txt:243 (add_subdirectory):
add_subdirectory given source "libobs-opengl" which is not an existing
directory.

CMake Error at CMakeLists.txt:244 (add_subdirectory):
add_subdirectory given source "libobs" which is not an existing directory.

CMake Error at CMakeLists.txt:245 (add_subdirectory):
add_subdirectory given source "plugins" which is not an existing directory.

CMake Error at CMakeLists.txt:246 (add_subdirectory):
add_subdirectory given source "UI" which is not an existing directory.

CMake Error at CMakeLists.txt:256 (add_subdirectory):
add_subdirectory given source "cmake/helper_subdir" which is not an
existing directory.

CMake Error at CMakeLists.txt:261 (include):
include could not find load file:

CopyMSVCBins

-- Configuring incomplete, errors occurred!
See also "/home/pi/ffmpeg-libraries/FFmpeg/obs-studio/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found. Stop.
make: *** No rule to make target 'install'. Stop.

All done..........

@rdmueller
Copy link

rdmueller commented Sep 4, 2020

thanx for creating this script.
unfortunately, I run into problems. The funny thing is, every time I run sudo make -j4 it gets a bit further but it will not succeed.

last error message I get is

make[2]: *** [plugins/obs-ffmpeg/ffmpeg-mux/CMakeFiles/obs-ffmpeg-mux.dir/build.make:87: plugins/obs-ffmpeg/ffmpeg-mux/obs-ffmpeg-mux] Error 1
make[1]: *** [CMakeFiles/Makefile2:1526: plugins/obs-ffmpeg/ffmpeg-mux/CMakeFiles/obs-ffmpeg-mux.dir/all] Error 2
make: *** [Makefile:152: all] Error 2

but I guess I have to start with the first error to analyze...

update:

Here are the last few lines of a fresh run:

/usr/bin/ld: /home/pi/ffmpeg-libraries/FFmpeg/libavformat/srtp.c:318: undefined reference to `av_hmac_update'
collect2: error: ld returned 1 exit status
make[2]: *** [plugins/obs-ffmpeg/ffmpeg-mux/CMakeFiles/obs-ffmpeg-mux.dir/build.make:87: plugins/obs-ffmpeg/ffmpeg-mux/obs-ffmpeg-mux] Error 1
make[1]: *** [CMakeFiles/Makefile2:1446: plugins/obs-ffmpeg/ffmpeg-mux/CMakeFiles/obs-ffmpeg-mux.dir/all] Error 2
make: *** [Makefile:152: all] Error 2

All done..........

It seems that it already fails to build the ffmpeg libraries...

Any idea what could be the problem?

Raspberry Pi 4 with 4GB and latest raspberrian full install

@jhamilt0n
Copy link

sudo cmake -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr ..
CMake Error: The source directory "/home/pi" does not appear to contain CMakeLists.txt.

I'm getting this error when trying to install. Any ideas on how to correct this?

@pseudofunizer
Copy link

pseudofunizer commented Apr 14, 2021

sudo cmake -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr ..
CMake Error: The source directory "/home/pi" does not appear to contain CMakeLists.txt.

I'm getting this error when trying to install. Any ideas on how to correct this?

You are in the wrong directory and are attempting to build so that CMake is referring to a non-existent file.

You can try instead i.e. (copy and paste the following highlighted text into the terminal if you know what you are doing ...):

cd $HOME && mkdir obs-tmp && cd obs-tmp && git clone --recursive https://github.com/obsproject/obs-studio.git && cd obs-studio && mkdir build && cd build && cmake -DBUILD_BROWSER=OFF -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr ..

Note that the -DBUILD_BROWSER=OFF flag will not build the browser source; also, good luck in getting the /opt/vc/lib/libEGL.so / libobsglad.so linking to work, that's where I'm stuck on the RPi4B at the moment myself. :P

@lweingart
Copy link

Hi, thank you for the script.
I was able to make it run smoothly, but when I try to run OBS I get a pop up with the following message:
"Error: Failed to initialize video. You GPU may not be supported, or your graphic drivers may need to be updated"

I have a brand new Raspberry 4 and installed the latest Raspberry OS:

$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

Would you have an idea what I could do next ?

Thank you for your esteemed help

@lweingart
Copy link

Hi again,

It appears that the solution is launching obs this way:
LIBGL_ALWAYS_SOFTWARE=1 obs

It did the trick at least for me.

Cheers everyone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment