Skip to content

Compile GStreamer

Joseph Lim edited this page Mar 13, 2021 · 1 revision

Clone gst-build repo and build it. I'm in Malaysia and the download speed is very low (~10Kbps) when cloning the subprojects in meson. On RPI, you can enable VNC server, and then use VNC viewer to open desktop and open terminal to start meson build. With this, your build won't stop when you close VNC Viewer so you can let it run overnight. The download could still timeout though.

For advanced users, you can manually change the meson build file to pull from GStreamer github mirror.

Instructions

# Clone build repo from Github mirror
git clone https://github.com/GStreamer/gst-build.git
cd gst-build
# For reference, here are some extra external libraries I installed for the compilation
# This is far from exhaustive, some might be optional
apt-get install libmount-dev flex bison nasm libssl-dev libavfilter-dev gobject-introspection \
  libgirepository1.0-dev libsrtp2-dev libjpeg-dev libvpx-dev libcairo2-dev
# Initialise build
meson builddir
# Configure build
meson configure -Dpython=enabled -Dgst-plugins-bad:webrtc=enabled -Dgst-plugins-base:opus=enabled \
  -Dgst-plugins-bad:srtp=enabled -Ddoc=disabled -Dgst-plugins-good:vpx=enabled builddir/
# Note: Check that cairo will not be compiled after configuring, as it may break your desktop
#       Install libcairo2-dev to prevent recompiling it
# Build
ninja -C builddir/
# Install (not recommended)
#ninja -C builddir/ install
# Use gst-build provided development environment for GStreamer.
# Option 1:
# Opens a new shell, not friendly to Visual Studio Code
ninja -C builddir/ devenv
# Option 2:
# Override environment variables to look for the recompiled GStreamer. Possible to add into .bashrc
eval $(~/gst-build/gst-env.py --builddir=$HOME/gst-build/builddir --srcdir=$HOME/gst-build --only-environment)
# Option 2.1:
# Getting the environment variable from the python script takes significant amount of time on my RPI 2.
# Since I believe it is static until the next time you recompile it, I save it into a file and load from there instead.
~/gst-build/gst-env.py --builddir=$HOME/gst-build/builddir --srcdir=$HOME/gst-build --only-environment \
  > ~/gst-env-static.txt
# There's a line setting PWD and OLDPWD inside gst-env-static.txt, and that is not static.
# Let's just comment them out or delete them manually. Then:
echo "source ~/gst-env-static.txt" >> ~/.bashrc

Test your installation by running "webrtc/janus/janusvideoroom.py" from gst-examples repo.

Tested on

  1. Debian 10
  2. Rasbian Buster

Note on Raspbian Stretch GStreamer

The Gstreamer version distributed with it is v1.10.1, and webrtcbin is first introduced in v1.13.1, referencing here.
So, still need to recompile GStreamer.

Clone this wiki locally