Skip to content

Instantly share code, notes, and snippets.

@Artistan
Forked from sphaero/gstreamer-build.sh
Last active August 12, 2018 01:05
Show Gist options
  • Save Artistan/212c4a44fa4f36ec2a0db7d32d29fe39 to your computer and use it in GitHub Desktop.
Save Artistan/212c4a44fa4f36ec2a0db7d32d29fe39 to your computer and use it in GitHub Desktop.
Install & build gstreamer from git
#!/bin/bash --debugger
export MAKEFLAGS="-j2"
set -e
#########################################
#
# ./script.sh [optional version]
#
# NOTES:
# make --> https://github.com/Tes3awy/OpenCV-3.2.0-Compiling-on-Raspberry-Pi#step-12
# RPi3 - https://gist.github.com/sphaero/02717b0b35501ad94863#gistcomment-1851352
# remove old streamer packages - https://gist.github.com/sphaero/02717b0b35501ad94863#gistcomment-1937640
# add rstp and raspcam - https://gist.github.com/sphaero/02717b0b35501ad94863#gistcomment-2026751
# add export to profile and python symlink - https://gist.github.com/sphaero/02717b0b35501ad94863#gistcomment-2089552
# update library names - https://raspberrypi.stackexchange.com/a/77642/72726
# and more info - https://github.com/popcornmix/omxplayer/pull/573/files
#########################################
BRANCH="1.12"
if grep -q BCM2835 /proc/cpuinfo; then
echo "RPI 1 BUILD - 700Mhz!"
RPI="1"
elif grep -q BCM2836 /proc/cpuinfo; then
echo "RPI 2 BUILD - 900Mhz!"
RPI="1"
elif grep -q BCM2837 /proc/cpuinfo; then
echo "RPI 2 v1.2 or RPI 3 BUILD - 1.2Ghz!"
RPI="1"
fi
[ -n "$1" ] && BRANCH=$1
# Create a log file of the build as well as displaying the build on the tty as it runs
exec > >(tee build_gstreamer.log)
exec 2>&1
# remove old streamer packages
sudo apt-get remove libgstreamer* gstreamer1.0* -y
sudo apt autoremove -y
# Update and Upgrade the Pi, otherwise the build may fail due to inconsistencies
grep -q BCM270 /proc/cpuinfo && sudo apt-get update && sudo apt-get upgrade -y --force-yes
grep -q BCM2835 /proc/cpuinfo && sudo apt-get update && sudo apt-get upgrade -y --force-yes
# Get the required libraries
sudo apt-get install -y --force-yes build-essential autotools-dev automake autoconf \
libtool autopoint libxml2-dev zlib1g-dev libglib2.0-dev \
pkg-config bison flex python3 git gtk-doc-tools libasound2-dev \
libgudev-1.0-dev libxt-dev libvorbis-dev libcdparanoia-dev \
libpango1.0-dev libtheora-dev libvisual-0.4-dev iso-codes \
libgtk-3-dev libraw1394-dev libiec61883-dev libavc1394-dev \
libv4l-dev libcairo2-dev libcaca-dev libspeex-dev libpng-dev \
libshout3-dev libjpeg-dev libaa1-dev libflac-dev libdv4-dev \
libtag1-dev libwavpack-dev libpulse-dev libsoup2.4-dev libbz2-dev \
libcdaudio-dev libdc1394-22-dev ladspa-sdk libass-dev \
libcurl4-gnutls-dev libdca-dev libdirac-dev libdvdnav-dev \
libexempi-dev libexif-dev libfaad-dev libgme-dev libgsm1-dev \
libiptcdata0-dev libkate-dev libmimic-dev libmms-dev \
libmodplug-dev libmpcdec-dev libofa0-dev libopus-dev \
librsvg2-dev librtmp-dev libschroedinger-dev libslv2-dev \
libsndfile1-dev libsoundtouch-dev libspandsp-dev libx11-dev \
libxvidcore-dev libzbar-dev libzvbi-dev liba52-0.7.4-dev \
libcdio-dev libdvdread-dev libmad0-dev libmp3lame-dev \
libmpeg2-4-dev libopencore-amrnb-dev libopencore-amrwb-dev \
libsidplay1-dev libtwolame-dev libx264-dev libusb-1.0 \
python-gi-dev yasm python3-dev libgirepository1.0-dev \
python-dev
## Minimal X:
sudo apt-get install --no-install-recommends xserver-xorg -y
sudo apt-get install --no-install-recommends xinit -y
# get the repos if they're not already there
cd $HOME
[ ! -d src ] && mkdir src
cd src
[ ! -d gstreamer ] && mkdir gstreamer
cd gstreamer
# get repos if they are not there yet
[ ! -d gstreamer ] && git clone git://anongit.freedesktop.org/git/gstreamer/gstreamer
[ ! -d gst-plugins-base ] && git clone git://anongit.freedesktop.org/git/gstreamer/gst-plugins-base
[ ! -d gst-plugins-good ] && git clone git://anongit.freedesktop.org/git/gstreamer/gst-plugins-good
[ ! -d gst-plugins-bad ] && git clone git://anongit.freedesktop.org/git/gstreamer/gst-plugins-bad
[ ! -d gst-plugins-ugly ] && git clone git://anongit.freedesktop.org/git/gstreamer/gst-plugins-ugly
[ ! -d gst-libav ] && git clone git://anongit.freedesktop.org/git/gstreamer/gst-libav
[ ! -d gst-omx ] && git clone git://anongit.freedesktop.org/git/gstreamer/gst-omx
[ ! -d gst-python ] && git clone git://anongit.freedesktop.org/git/gstreamer/gst-python
[ ! -d gst-rtsp-server ] && git clone git://anongit.freedesktop.org/gstreamer/gst-rtsp-server
if [[ $RPI -eq 1 ]]; then
[ ! -d gst-rpicamsrc ] && git clone https://github.com/thaytan/gst-rpicamsrc.git
else
[ ! $RPI ] && [ ! -d gstreamer-vaapi ] && git clone git://anongit.freedesktop.org/gstreamer/gstreamer-vaapi
fi
export LD_LIBRARY_PATH=/usr/local/lib/
# checkout branch (default=master) and build & install
cd gstreamer
git checkout -t origin/$BRANCH || true
sudo make uninstall || true
git pull
./autogen.sh --disable-gtk-doc
sudo make
sudo make install
cd ..
cd gst-plugins-base
git checkout -t origin/$BRANCH || true
sudo make uninstall || true
git pull
./autogen.sh --disable-gtk-doc
sudo make
sudo make install
cd ..
cd gst-plugins-good
git checkout -t origin/$BRANCH || true
sudo make uninstall || true
git pull
./autogen.sh --disable-gtk-doc
sudo make
sudo make install
cd ..
cd gst-plugins-ugly
git checkout -t origin/$BRANCH || true
sudo make uninstall || true
git pull
./autogen.sh --disable-gtk-doc
sudo make
sudo make install
cd ..
cd gst-libav
git checkout -t origin/$BRANCH || true
sudo make uninstall || true
git pull
./autogen.sh --disable-gtk-doc
sudo make
sudo make install
cd ..
cd gst-plugins-bad
git checkout -t origin/$BRANCH || true
sudo make uninstall || true
git pull
# some extra flags on rpi
if [[ $RPI -eq 1 ]]; then
export LDFLAGS='-L/opt/vc/lib' \
CFLAGS='-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux' \
CPPFLAGS='-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux'
./autogen.sh --disable-gtk-doc --disable-examples --disable-x11 --disable-glx --disable-glx --disable-opengl
make CFLAGS+="-Wno-error -Wno-redundant-decls -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux" \
CPPFLAGS+="-Wno-error -Wno-redundant-decls -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux" \
CXXFLAGS+="-Wno-redundant-decls" LDFLAGS+="-L/opt/vc/lib"
else
./autogen.sh --disable-gtk-doc
make CFLAGS+="-Wno-error -Wno-redundant-decls" CXXFLAGS+="-Wno-redundant-decls"
fi
sudo make install
cd ..
# python bindings
cd gst-python
git checkout -t origin/$BRANCH || true
export LD_LIBRARY_PATH=/usr/local/lib/
sudo make uninstall || true
git pull
PYTHON=/usr/bin/python3 ./autogen.sh
sudo make
sudo make install
cd ..
# omx support
cd gst-omx
git checkout -t origin/$BRANCH || true
sudo make uninstall || true
git pull
if [[ $RPI -eq 1 ]]; then
export LDFLAGS='-L/opt/vc/lib' \
CFLAGS='-I/opt/vc/include -I/opt/vc/include/IL -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/IL' \
CPPFLAGS='-I/opt/vc/include -I/opt/vc/include/IL -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/IL'
./autogen.sh --disable-gtk-doc --with-omx-target=rpi
# fix for glcontext errors and openexr redundant declarations - https://gist.github.com/sphaero/02717b0b35501ad94863#gistcomment-1982767
make CFLAGS+="-Wno-error -Wno-redundant-decls" LDFLAGS+="-L/opt/vc/lib -lbrcmEGL -lbrcmGLESv2 -lbcm_host"
else
./autogen.sh --disable-gtk-doc --with-omx-target=bellagio
# fix for glcontext errors and openexr redundant declarations
make CFLAGS+="-Wno-error -Wno-redundant-decls"
fi
sudo make install
cd ..
# VAAPI, not for RPI
if [[ $RPI -ne 1 ]]; then
cd gstreamer-vaapi
sudo make uninstall || true
git pull
./autogen.sh
make
sudo make install
cd ..
fi
# Gstreamer Raspberry Pi Camera Wrapper
if [[ $RPI -eq 1 ]]; then
cd gst-rpicamsrc
sudo make uninstall || true
git pull
./autogen.sh --prefix=/usr --libdir=/usr/lib/arm-linux-gnueabihf/
sudo make
sudo make install
cd ..
fi
# Gstreamer RTSP Server
cd gst-rtsp-server
git checkout -t origin/$BRANCH || true
sudo make uninstall || true
git pull
./autogen.sh --disable-gtk-doc
sudo make
sudo make install
cd ..
# library path
echo "export GST_PLUGIN_PATH=/usr/local/lib/gstreamer-1.0/" >> ~/.profile
echo "export GST_OMX_CONFIG_DIR=/usr/local/etc/xdg/" >> ~/.profile
echo "export LD_LIBRARY_PATH=/usr/local/lib/" >> ~/.profile
echo "export GI_TYPELIB_PATH=/usr/local/lib/girepository-1.0/" >> ~/.profile
sudo ln -s /usr/lib/arm-linux-gnueabihf/libpython3.4m.so /usr/lib/libpython3.4m.so
sudo sh -c 'echo none > /sys/class/leds/led0/trigger'
sudo sh -c 'echo none > /sys/class/leds/led1/trigger'
sudo sh -c 'echo 0 > /sys/class/leds/led0/brightness'
sudo sh -c 'echo 0 > /sys/class/leds/led1/brightness'
sudo shutdown -r now
@Artistan
Copy link
Author

Total count: 213 plugins (15 blacklist entries not shown), 1256 features

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