Skip to content

Instantly share code, notes, and snippets.

@admalledd
Last active September 20, 2016 10:03
Show Gist options
  • Save admalledd/22096af58ee1eaa301d7 to your computer and use it in GitHub Desktop.
Save admalledd/22096af58ee1eaa301d7 to your computer and use it in GitHub Desktop.
Helper script to compile obs-studio. Gets the needed depenancies for you!
#!/bin/bash
set -e #quit on error stuff!
#This script was only testing on linux mint 16, with a large pile of custom tweaking.
#This file should be used more as a "guide line" than anything else...
# PLEASE edit certain settings before going around and running this! to make sure of that I
# have the next line kill the script unless commented out!
echo "You forgot to set up this file! Edit it with correct paths to use!" && exit 0
#these are the pathing options on where to build/install things.
DEVROOT=$HOME/dev2
#where the building of ffmpeg happens
FFMPEGROOT=$DEVROOT/ffmpeg
#where the dev stuff of qt5 is installed
#Note that for QT you should probably check down lower and see if there are any updates (defaults to 5.3.0) instead of this hard-coded URL
QTROOT=$DEVROOT/qt
#in the end, install everything "here" (qt5,ffmpeg,obs), in the root of this dir will be the launcher script for obs
INSTALLROOT=$HOME/bin/obs
#become the first thing in the path, in case the system has borked stuff (looking at you libav...)
export PATH=$INSTALLROOT/bin:$PATH
#if you are a multi-core computer modify the number here to your cores +1/4 (speeds up compile!)
MAKEJOBS=-j4
#-------CONFIG OPTIONS DONE!
mkdir -p $DEVROOT/flags
log_stuff () {
echo -e "\033[1;33m$1\033[0m"
}
# lets get all of those pesky build-deps installed for ffmpeg
if [[ ! -f $DEVROOT/flags/apt-get ]]; then
log_stuff "installing apt-get-able deps..."
sudo apt-get update
sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev \
libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev \
libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev \
yasm libmp3lame-dev libopus-dev p7zip-full git
#if your *buntu does not have "yasm", "libmp3lame-dev", "libopus-dev"
# of the correct versions: follow https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
touch $DEVROOT/flags/apt-get
else
log_stuff "already installed apt-get-able deps..."
fi
mkdir -p $FFMPEGROOT
#---- FFMPEG stuff
# libx264
cd $FFMPEGROOT
if [[ ! -f $DEVROOT/flags/libx264.download ]]; then
log_stuff "downloading libx264"
wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
touch $DEVROOT/flags/libx264.download
else
log_stuff "already downloaded libx264"
fi
if [[ ! -f $DEVROOT/flags/libx264.extract ]]; then
log_stuff "extracting libx264"
tar xjvf last_x264.tar.bz2
touch $DEVROOT/flags/libx264.extract
else
log_stuff "already extracted libx264"
fi
cd x264-snapshot*
if [[ ! -f $DEVROOT/flags/libx264.configure ]]; then
log_stuff "configuring libx264"
./configure --prefix="$INSTALLROOT" --enable-shared
touch $DEVROOT/flags/libx264.configure
else
log_stuff "already configured libx264"
fi
if [[ ! -f $DEVROOT/flags/libx264.compile ]]; then
log_stuff "compiling libx264"
make $MAKEJOBS
touch $DEVROOT/flags/libx264.compile
else
log_stuff "already compiled libx264"
fi
if [[ ! -f $DEVROOT/flags/libx264.install ]]; then
log_stuff "installing libx264"
make install
touch $DEVROOT/flags/libx264.install
else
log_stuff "already installed libx264"
fi
#libfdk-aac
cd $FFMPEGROOT
if [[ ! -f $DEVROOT/flags/libfdk-aac.download ]]; then
log_stuff "downloading libfdk-aac"
wget -O fdk-aac.zip https://github.com/mstorsjo/fdk-aac/zipball/master
touch $DEVROOT/flags/libfdk-aac.download
else
log_stuff "already downloaded libfdk-aac"
fi
if [[ ! -f $DEVROOT/flags/libfdk-aac.extract ]]; then
log_stuff "extracting libfdk-aac"
unzip fdk-aac.zip
touch $DEVROOT/flags/libfdk-aac.extract
else
log_stuff "already extracted libfdk-aac"
fi
cd mstorsjo-fdk-aac*
if [[ ! -f $DEVROOT/flags/libfdk-aac.configure ]]; then
log_stuff "configuring libfdk-aac"
autoreconf -fiv
./configure --prefix="$INSTALLROOT" --enable-shared
touch $DEVROOT/flags/libfdk-aac.configure
else
log_stuff "already configured libfdk-aac"
fi
if [[ ! -f $DEVROOT/flags/libfdk-aac.compile ]]; then
log_stuff "compiling libfdk-aac"
make $MAKEJOBS
touch $DEVROOT/flags/libfdk-aac.compile
else
log_stuff "already compiled libfdk-aac"
fi
if [[ ! -f $DEVROOT/flags/libfdk-aac.install ]]; then
log_stuff "installing libfdk-aac"
make install
touch $DEVROOT/flags/libfdk-aac.install
else
log_stuff "already installed libfdk-aac"
fi
#libvpx
cd $FFMPEGROOT
if [[ ! -f $DEVROOT/flags/libvpx.download ]]; then
log_stuff "downloading libvpx"
wget http://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
touch $DEVROOT/flags/libvpx.download
else
log_stuff "already downloaded libvpx"
fi
if [[ ! -f $DEVROOT/flags/libvpx.extract ]]; then
log_stuff "extracting "
tar xjvf libvpx-v1.3.0.tar.bz2
touch $DEVROOT/flags/libvpx.extract
else
log_stuff "already extracted libvpx"
fi
cd libvpx-v1.3.0
if [[ ! -f $DEVROOT/flags/libvpx.configure ]]; then
log_stuff "configuring libvpx"
./configure --prefix="$INSTALLROOT" --enable-shared --disable-examples
touch $DEVROOT/flags/libvpx.configure
else
log_stuff "already configured libvpx"
fi
if [[ ! -f $DEVROOT/flags/libvpx.compile ]]; then
log_stuff "compiling libvpx"
make $MAKEJOBS
touch $DEVROOT/flags/libvpx.compile
else
log_stuff "already compiled libvpx"
fi
if [[ ! -f $DEVROOT/flags/libvpx.install ]]; then
log_stuff "installing libvpx"
make install
touch $DEVROOT/flags/libvpx.install
else
log_stuff "already installed libvpx"
fi
#ffmpeg
cd $FFMPEGROOT
if [[ ! -f $DEVROOT/flags/ffmpeg.download ]]; then
log_stuff "downloading ffmpeg"
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
touch $DEVROOT/flags/ffmpeg.download
else
log_stuff "already downloaded ffmpeg"
fi
if [[ ! -f $DEVROOT/flags/ffmpeg.extract ]]; then
log_stuff "extracting ffmpeg"
tar xjvf ffmpeg-snapshot.tar.bz2
touch $DEVROOT/flags/ffmpeg.extract
else
log_stuff "already extracted ffmpeg"
fi
cd ffmpeg
if [[ ! -f $DEVROOT/flags/ffmpeg.configure ]]; then
log_stuff "configuring ffmpeg"
PKG_CONFIG_PATH="$INSTALLROOT/lib/pkgconfig"
export PKG_CONFIG_PATH
./configure --prefix="$INSTALLROOT" --extra-cflags="-I$INSTALLROOT/include" \
--extra-ldflags="-L$INSTALLROOT/lib" --extra-libs="-ldl" --enable-gpl \
--enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus \
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab \
--enable-shared
touch $DEVROOT/flags/ffmpeg.configure
else
log_stuff "already configured ffmpeg"
fi
if [[ ! -f $DEVROOT/flags/ffmpeg.compile ]]; then
log_stuff "compiling ffmpeg"
make $MAKEJOBS
touch $DEVROOT/flags/ffmpeg.compile
else
log_stuff "already compiled ffmpeg"
fi
if [[ ! -f $DEVROOT/flags/ffmpeg.install ]]; then
log_stuff "installing ffmpeg"
make install
touch $DEVROOT/flags/ffmpeg.install
else
log_stuff "already installed ffmpeg"
fi
#----------------QT STUFF
log_stuff "Cheating the QT installer, most likely place for downloading and such to fail..."
#./qt-opensource-linux-x64-5.3.0.run
mkdir -p $QTROOT
cd $QTROOT
if [[ ! -f $DEVROOT/flags/qt.download ]]; then
log_stuff "downloading qt5"
wget http://download.qt-project.org/online/qtsdkrepository/linux_x64/desktop/qt5_53/qt.53.gcc_64/5.3.0-1icu_52_1_ubuntu_11_10_64.7z
wget http://download.qt-project.org/online/qtsdkrepository/linux_x64/desktop/qt5_53/qt.53.gcc_64/5.3.0-1qt5_addons.7z
wget http://download.qt-project.org/online/qtsdkrepository/linux_x64/desktop/qt5_53/qt.53.gcc_64/5.3.0-1qt5_essentials.7z
touch $DEVROOT/flags/qt.download
else
log_stuff "already downloaded qt5"
fi
if [[ ! -f $DEVROOT/flags/qt.extract ]]; then
log_stuff "extracting qt5"
7z x 5.3.0-1qt5_essentials.7z
7z x 5.3.0-1qt5_addons.7z
7z x 5.3.0-1icu_52_1_ubuntu_11_10_64.7z
touch $DEVROOT/flags/qt.extract
else
log_stuff "already extracted qt5"
fi
if [[ ! -f $DEVROOT/flags/qt.install ]]; then
log_stuff "installing qt5"
cp -r 5.3/gcc_64/* $INSTALLROOT/
touch $DEVROOT/flags/qt.install
else
log_stuff "already installed qt5"
fi
#get us a version of cmake that works. I had no PPA that had it, system version was too old...
cd $DEVROOT
if [[ ! -f $DEVROOT/flags/cmake.download ]]; then
log_stuff "downloading cmake"
wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2-Linux-i386.tar.gz
touch $DEVROOT/flags/cmake.download
else
log_stuff "already downloaded cmake"
fi
if [[ ! -f $DEVROOT/flags/cmake.install ]]; then
log_stuff "installing cmake"
#per reading the man page on tar the strip components may not be standard and need tweaking on some (even odder) systems
tar --strip-components=1 -zxvf cmake-2.8.12.2-Linux-i386.tar.gz -C $INSTALLROOT
touch $DEVROOT/flags/cmake.install
else
log_stuff "already installed cmake"
fi
#this should put obs-src in $DEVROOT/obs-studio
log_stuff "getting copy of obs-studio source from github"
git clone https://github.com/jp9000/obs-studio.git
#we should now have all of the basic dependencies down, echo out the custom build script
log_stuff "making helper compile and run scripts"
cat << HERE_DOC_EOF_NO_MANGLE > $DEVROOT/build_obs.sh
#!/bin/bash
#cheating path init...
export PATH=$PATH
#no more path cheating...
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INSTALLROOT/lib
export CMAKE_INCLUDE_PATH=$INSTALLROOT/include
export CMAKE_PREFIX_PATH=$INSTALLROOT
mkdir -p $DEVROOT/obs-build
cd $DEVROOT/obs-build
cmake -DCMAKE_INSTALL_PREFIX:PATH=$INSTALLROOT ../obs-studio
make $MAKEJOBS
HERE_DOC_EOF_NO_MANGLE
chmod +x $DEVROOT/build_obs.sh
cat << HERE_DOC_EOF_NO_MANGLE > $INSTALLROOT/run_obs.sh
#!/bin/bash
#cheating path init...
export PATH=$PATH
#no more path cheating...
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INSTALLROOT/lib
#qt plugins are a pain...
export QT_PLUGIN_PATH=/home/admalledd/bin/obs/plugins
cd $INSTALLROOT
bin/obs
HERE_DOC_EOF_NO_MANGLE
chmod +x $INSTALLROOT/run_obs.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment