Skip to content

Instantly share code, notes, and snippets.

@sphaero
Last active February 11, 2023 16:25
Show Gist options
  • Save sphaero/02717b0b35501ad94863 to your computer and use it in GitHub Desktop.
Save sphaero/02717b0b35501ad94863 to your computer and use it in GitHub Desktop.
Install & build gstreamer from git
#!/bin/bash --debugger
set -e
BRANCH="master"
if grep -q BCM2708 /proc/cpuinfo; then
echo "RPI BUILD!"
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
# Update and Upgrade the Pi, otherwise the build may fail due to inconsistencies
grep -q BCM2708 /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
# 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
[ ! $RPI ] && [ ! -d gstreamer-vaapi ] && git clone git://gitorious.org/vaapi/gstreamer-vaapi.git
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
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
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
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
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
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
make
sudo make install
cd ..
# omx support
cd gst-omx
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
make CFLAGS+="-Wno-error -Wno-redundant-decls" LDFLAGS+="-L/opt/vc/lib"
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
@vpolimenov
Copy link

I am getting the following:

make[5]: Entering directory '/home/pi/src/gstreamer/gst-plugins-base/gst-libs/gst/video'
  CC       libgstvideo_1.0_la-colorbalance.lo
  CC       libgstvideo_1.0_la-colorbalancechannel.lo
  CC       libgstvideo_1.0_la-navigation.lo
  CC       libgstvideo_1.0_la-video.lo
  CC       libgstvideo_1.0_la-video-anc.lo
video-anc.c:617:5: error: "G_GNUC_CHECK_VERSION" is not defined [-Werror=undef]
 #if G_GNUC_CHECK_VERSION(3,4)
     ^
video-anc.c:617:25: error: missing binary operator before token "("
 #if G_GNUC_CHECK_VERSION(3,4)
                         ^
cc1: all warnings being treated as errors

@kevkid
Copy link

kevkid commented Dec 22, 2018

this is insane! getting this from a fresh pull.

In file included from gst_private.h:49:0,
                 from gstpad.c:90:
gstpad.c: In function ‘cleanup_hook’:
gstpad.c:1376:7: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but a
rgument 8 has type ‘gulong {aka long unsigned int}’ [-Werror=format=]
       "cleaning up hook %" G_GUINT64_FORMAT " with flags %08x", hook->hook_id,
       ^
gstinfo.h:640:31: note: in definition of macro ‘GST_CAT_LEVEL_LOG’
         (GObject *) (object), __VA_ARGS__);    \
                               ^~~~~~~~~~~
gstpad.c:1375:3: note: in expansion of macro ‘GST_DEBUG_OBJECT’
   GST_DEBUG_OBJECT (pad,
   ^~~~~~~~~~~~~~~~
  CC       libgstreamer_1.0_la-gstparamspecs.lo
  CC       libgstreamer_1.0_la-gstpipeline.lo
  CC       libgstreamer_1.0_la-gstplugin.lo
  CC       libgstreamer_1.0_la-gstpluginfeature.lo
  CC       libgstreamer_1.0_la-gstpluginloader.lo
  CC       libgstreamer_1.0_la-gstpoll.lo
  CC       libgstreamer_1.0_la-gstpreset.lo
  CC       libgstreamer_1.0_la-gstprotection.lo
  CC       libgstreamer_1.0_la-gstquark.lo
  CC       libgstreamer_1.0_la-gstquery.lo
  CC       libgstreamer_1.0_la-gstregistry.lo
  CC       libgstreamer_1.0_la-gstregistrychunks.lo
cc1: all warnings being treated as errors
Makefile:1363: recipe for target 'libgstreamer_1.0_la-gstpad.lo' failed
make[4]: *** [libgstreamer_1.0_la-gstpad.lo] Error 1
make[4]: *** Waiting for unfinished jobs....
make[4]: Leaving directory '/root/src/gstreamer/gstreamer/gst'
Makefile:1732: recipe for target 'all-recursive' failed
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory '/root/src/gstreamer/gstreamer/gst'
Makefile:936: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/root/src/gstreamer/gstreamer/gst'
Makefile:742: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/root/src/gstreamer/gstreamer'
Makefile:648: recipe for target 'all' failed
make: *** [all] Error 2

I can comment out the offending code but surprise surprise there are more errors.

Anyone else get this error on a raspberry pi 3 b+?

@grkblood13
Copy link

I'd like to suggest adding rock64 support as well

@jhihn
Copy link

jhihn commented Jan 6, 2021

The RPI detection does not work on a PI Zero, that has a BCM2835 chip.
Probably line 5 grep -q BCM2

@lakis1982
Copy link

lakis1982 commented Feb 21, 2021

Hello,

@sphaero @johnboiles thanks for providing this script. I tried to use it in order to install the latest gstreamer on my raspberry pi 3, but it fails..
If in line 4 of your script I specify BRANCH="1.18" and then i run the script, it gives the following error and the installation stops.. If BRANCH="master" it still gives error..

$ sudo ./gstreamer-build.sh
./gstreamer-build.sh: /usr/share/bashdb/bashdb-main.inc: No such file or directory
./gstreamer-build.sh: warning: cannot start debugger; debugging mode disabled
Reading package lists...
Building dependency tree...
Reading state information...
autoconf is already the newest version (2.69-11).
automake is already the newest version (1:1.16.1-4).
autopoint is already the newest version (0.19.8.1-9).
autotools-dev is already the newest version (20180224.1).
bison is already the newest version (2:3.3.2.dfsg-1).
build-essential is already the newest version (12.6).
flex is already the newest version (2.6.4-6.2).
gettext is already the newest version (0.19.8.1-9).
git is already the newest version (1:2.20.1-2+deb10u3).
gtk-doc-tools is already the newest version (1.28-1).
iso-codes is already the newest version (4.2-1).
ladspa-sdk is already the newest version (1.13-3).
liba52-0.7.4-dev is already the newest version (0.7.4-19).
libaa1-dev is already the newest version (1.4p5-46).
libass-dev is already the newest version (1:0.14.0-2).
libavc1394-dev is already the newest version (0.5.4-5).
libbz2-dev is already the newest version (1.0.6-9.2deb10u1).
libcaca-dev is already the newest version (0.99.beta19-2.1).
libcdaudio-dev is already the newest version (0.99.12p2-14).
libcdio-dev is already the newest version (2.0.0-2).
libcdparanoia-dev is already the newest version (3.10.2+debian-13).
libcurl4-gnutls-dev is already the newest version (7.64.0-4+deb10u1).
libdc1394-22-dev is already the newest version (2.2.5-1).
libdca-dev is already the newest version (0.0.6-1).
libdv4-dev is already the newest version (1.0.0-12).
libdvdnav-dev is already the newest version (6.0.0-1).
libdvdread-dev is already the newest version (6.0.1-1).
libexempi-dev is already the newest version (2.5.0-2).
libexif-dev is already the newest version (0.6.21-5.1+deb10u5).
libfaad-dev is already the newest version (2.8.8-3).
libflac-dev is already the newest version (1.3.2-3).
libgirepository1.0-dev is already the newest version (1.58.3-2).
libglib2.0-dev is already the newest version (2.58.3-2+deb10u2).
libgme-dev is already the newest version (0.6.2-1).
libgsm1-dev is already the newest version (1.0.18-2).
libgudev-1.0-dev is already the newest version (232-2+rpi1).
libiec61883-dev is already the newest version (1.2.0-3).
libiptcdata0-dev is already the newest version (1.0.5-2.1).
libjpeg-dev is already the newest version (1:1.5.2-2+deb10u1).
libkate-dev is already the newest version (0.4.1-9).
libmad0-dev is already the newest version (0.15.1b-10).
libmimic-dev is already the newest version (1.0.4-2.3).
libmms-dev is already the newest version (0.6.4-3).
libmodplug-dev is already the newest version (1:0.8.9.0-2).
libmp3lame-dev is already the newest version (3.100-2+b1).
libmpcdec-dev is already the newest version (2:0.1
r495-1+b1).
libmpeg2-4-dev is already the newest version (0.5.1-8).
libofa0-dev is already the newest version (0.9.3-19).
libopencore-amrnb-dev is already the newest version (0.1.3-2.1).
libopencore-amrwb-dev is already the newest version (0.1.3-2.1).
libopus-dev is already the newest version (1.3-1).
libpango1.0-dev is already the newest version (1.42.4-8deb10u1).
libpng-dev is already the newest version (1.6.36-6).
libraw1394-dev is already the newest version (2.1.2-1+b1).
librsvg2-dev is already the newest version (2.44.10-2.1+rpi1).
librtmp-dev is already the newest version (2.4+20151223.gitfa8646d.1-2).
libschroedinger-dev is already the newest version (1.0.11-2.1).
libshout3-dev is already the newest version (2.4.1-2).
libsidplay1-dev is already the newest version (1.36.59-11).
libslv2-dev is already the newest version (0.6.6+dfsg1-3).
libsndfile1-dev is already the newest version (1.0.28-6).
libsoundtouch-dev is already the newest version (2.1.2+ds1-1).
libsoup2.4-dev is already the newest version (2.64.2-2).
libspandsp-dev is already the newest version (0.0.6+dfsg-2).
libspeex-dev is already the newest version (1.2
rc1.2-1+b2).
libtag1-dev is already the newest version (1.11.1+dfsg.1-0.3+deb10u1).
libtheora-dev is already the newest version (1.1.1+dfsg.1-15).
libtool is already the newest version (2.4.6-9).
libtwolame-dev is already the newest version (0.3.13-4).
libusb-1.0-0 is already the newest version (2:1.0.22-2).
libusb-1.0-0-dev is already the newest version (2:1.0.22-2).
libusb-1.0-doc is already the newest version (2:1.0.22-2).
libv4l-dev is already the newest version (1.16.3-3).
libvisual-0.4-dev is already the newest version (0.4.0-15).
libvorbis-dev is already the newest version (1.3.6-2).
libwavpack-dev is already the newest version (5.1.0-6).
libx11-dev is already the newest version (2:1.6.7-1+deb10u1).
libx264-dev is already the newest version (2:0.155.2917+git0a84d98-2+rpi1).
libxml2-dev is already the newest version (2.9.4+dfsg1-7+deb10u1).
libxt-dev is already the newest version (1:1.1.5-1+b3).
libxvidcore-dev is already the newest version (2:1.3.5-1).
libzbar-dev is already the newest version (0.22-1).
libzvbi-dev is already the newest version (0.2.35-16).
pkg-config is already the newest version (0.29-6).
python-gi-dev is already the newest version (3.30.4-1).
python3 is already the newest version (3.7.3-1).
python3-dev is already the newest version (3.7.3-1).
yasm is already the newest version (1.3.0-2).
zlib1g-dev is already the newest version (1:1.2.11.dfsg-1).
libasound2-dev is already the newest version (1.1.8-1+rpt1).
libcairo2-dev is already the newest version (1.16.0-4+rpt1).
libgtk-3-dev is already the newest version (3.24.5-1+rpt2).
libpulse-dev is already the newest version (12.2-4+deb10u1+rpi3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
W: --force-yes is deprecated, use one of the options starting with --allow instead.
Switched to a new branch '1.18'
Branch '1.18' set up to track remote branch '1.18' from 'origin'.
make: *** No rule to make target 'uninstall'. Stop.
Already up to date.
./gstreamer-build.sh: line 67: ./autogen.sh: No such file or directory

Could you please help me with that ? How to install the latest gstreamer on my rapsberry pi 3 ?

thanks a lot

@sphaero
Copy link
Author

sphaero commented Feb 21, 2021

The script is very old so probably things have changed either in the distro or in gstreamer. Any of the forks have better luck? I hadn't noticed so many people responded to this script. A proper git repo would have served it better. 😬

@lakis1982
Copy link

Dear @sphaero

i think that the problem is in the gstreamer branch 1.18 because i see that there is no file .autogen and your script tries to execute this and fails. I dont even know what is the purpose of this file.. I also dont know what is the meaning of command sudo make uninstall || true because it also gives the error make: *** No rule to make target 'uninstall'. Stop.

I dont have any programming knowledge and i am a complete newbie. Is there any quick way to make this script work ? Or any other alternative commands that i could run in order to instal gstreamer 1.18 on my rapsberry pi 3 ?

Thanks a lot

@sphaero
Copy link
Author

sphaero commented Feb 21, 2021

@lakis1982
Copy link

@sphaero following the link you mentioned I can install gstreamer through apt-get command but it installs version 1.14.. I need version 1.18..
I have raspberry pi 3 and in the /etc/apt/sources.list there is only one line inside as deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

do you know if there is another specific repository that contains the latest gstreamer version ?

I am sorry but as I said I am completely novice user.. I just wish I could run apt-get install gstreamer1.0 so that gstreamer v1.18 could be installed ...But this command install v1.14

@mylselgan
Copy link

Hi @sphaero it seems that Gstreamer moved to github. The new repository link is https://github.com/GStreamer/
Could you please update your gist accordingly. Your gist was useful to install the latest Gstreamer in one command but is not working anymore.
the link provided by you above (installing through apt-get) only installs the old version.
Thanks.

@sphaero
Copy link
Author

sphaero commented Jul 12, 2022

I think that's just a mirror, they moved to gitlab I think. I'd need to look into it but if you have a patch that'd be great.

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