Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
#
# Build gstreamer for Raspberry Pi
# Edit the SRC and DEST environment variables at the top and then
# run this script. You'll need to add the following two envronment
# variables to your .profile
#
# LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${PREFIX}/lib"
# PATH="${PATH}:${PREFIX}/bin"
#
# Then logout and log back in again.
#
# Author: David Thorpe <djt@mutablelogic.com>
# Install parameters
SRC="${HOME}/projects/gstreamer"
DEST="/opt"
PREFIX="${DEST}/gstreamer"
VC="/opt/vc/lib/pkgconfig"
# Preamble
echo GStreamer installation:
echo
echo " SRC=${SRC}"
echo " PREFIX=${PREFIX}"
echo
# Create build folder
if [ ! -d "${SRC}" ]; then
install -d "${SRC}" || exit -1
fi
# Munge pkgconfig
cd "${VC}"
if [ ! -f "${VC}/egl.pc" ]; then
sudo ln -s brcmegl.pc egl.pc
fi
if [ ! -f "${VC}/glesv2.pc" ]; then
sudo ln -s brcmglesv2.pc glesv2.pc
fi
# Create destination folders
if [ ! -w "${DEST}" ]; then
sudo chgrp users "${DEST}"
sudo chmod g+w "${DEST}"
fi
if [ ! -d "${PREFIX}" ]; then
install -d "${PREFIX}" || exit -1
fi
# Install dependencies
sudo apt-get -y -q install \
meson libglib2.0-dev flex bison \
libvorbis-dev libtheora-dev libflac-dev libdv4-dev \
libwavpack-dev libopus-dev liba52-0.7.4-dev \
libmp3lame-dev libmpeg2-4-dev libx264-dev libx265-dev \
libsoup2.4-dev
# Get gst-build repo
cd "${SRC}"
[ ! -d gst-build ] && git clone git://anongit.freedesktop.org/git/gstreamer/gst-build
# Configure and build
cd "${SRC}/gst-build"
PKG_CONFIG_PATH="${VC}" meson --prefix="${PREFIX}" build \
-D gst-plugins-base:gl_api=gles2 \
-D gst-plugins-base:gl_platform=egl \
-D gst-plugins-base:gl_winsys=dispmanx \
-D gst-plugins-base:gles2_module_name=/opt/vc/lib/libbrcmGLESv2.so \
-D gst-plugins-base:egl_module_name=/opt/vc/lib/libbrcmEGL.so \
-D gst-plugins-bad:bluez=disabled -D gst-plugins-bad:opencv=disabled -D bad=enabled \
-D omx=enabled -D gst-omx:header_path=/opt/vc/include/IL -D gst-omx:target=rpi \
-D python=disabled -D introspection=disabled -D examples=disabled || exit -1
ninja -C build install || exit -1
# End with success
echo
echo Add the following lines to your .profile file:
echo
echo " LD_LIBRARY_PATH=\"\${LD_LIBRARY_PATH}:${PREFIX}/lib\""
echo " PATH=\"\${PATH}:${PREFIX}/bin\""
echo
echo ...then logout and log back in again.
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment