Generating a GStreamer-1.14 bundle for TravisCI with Ubuntu/Trusty
For having continuous integration in your multimedia project hosted in GitHub with TravisCI, you may want to compile and run tests with a recent version of GStreamer. Nonetheless, TravisCI mainly offers Ubuntu Trusty as one of the possible distributions to deploy in their CI, and that distribution packages GStreamer 1.2, which might be a bit old for your project’s requirements.A solution for this problem is to provide to TravisCI your own GStreamer bundle with the version you want to compile and test on you project, in this case 1.14. The present blog is recipe I followed to generate that GStreamer bundle with GstGL support.
There are three main issues:
- The packaged libglib version is too old, hoping that we will not find an ABI breakage while running the CI.
- The packaged FFmpeg version is too old
- As we want to compile GStreamer using gst-build, we need a recent version of meson, which requires python3.5, not available in Trusty.
schroot #
Old habits die hard, and I have used schroot
for handle chroot environments without
complains, it handles the bind mounting of /proc
, /sys
and all that
repetitive stuff that seals the isolation of the chrooted environment.
The debootstrap’s variant I use is buildd
because it installs the
build-essential package.
sudo mkdir /srv/chroot/gst-trusty64
sudo debootstrap --arch=amd64 --variant=buildd trusty ./gst-trusty64/ http://archive.ubuntu.com/ubuntu
sudo vim /etc/schroot/chroot.d
This is the schroot configuration I will use. Please, adapt it to your need.
[gst]
description=Ubuntu Trusty 64-bit for GStreamer
directory=/srv/chroot/gst-trusty64
type=directory
users=vjaquez
root-users=vjaquez
profile=default
setup.fstab=default/vjaquez-home.fstab
I am overriding the fstab
default file for a custom one where the home
directory of vjaquez user aims to a clean directory.
mkdir -p ~/home-chroot/gst
sudo vim /etc/schroot/default/vjaquez-home.fstab
# fstab: static file system information for chroots.
# Note that the mount point will be prefixed by the chroot path
# (CHROOT_PATH)
#
#
/proc /proc none rw,bind 0 0
/sys /sys none rw,bind 0 0
/dev /dev none rw,bind 0 0
/dev/pts /dev/pts none rw,bind 0 0
/home /home none rw,bind 0 0
/home/vjaquez/home-chroot/gst /home/vjaquez none rw,bind 0 0
/tmp /tmp none rw,bind 0 0
configure chroot environment #
We will get into the chroot environment as super user in order to add the
required packages. For that purpose we add universe repository in apt
.
- libglib requires: autotools-dev gnome-pkg-tools libtool libffi-dev libelf-dev libpcre3-dev desktop-file-utils libselinux1-dev libgamin-dev dbus dbus-x11 shared-mime-info libxml2-utils
- Python requires: libssl-dev libreadline-dev libsqlite3-dev
- GStreamer requires: bison flex yasm python3-pip libasound2-dev libbz2-dev libcap-dev libdrm-dev libegl1-mesa-dev libfaad-dev libgl1-mesa-dev libgles2-mesa-dev libgmp-dev libgsl0-dev libjpeg-dev libmms-dev libmpg123-dev libogg-dev libopus-dev liborc-0.4-dev libpango1.0-dev libpng-dev libpulse-dev librtmp-dev libtheora-dev libtwolame-dev libvorbis-dev libvpx-dev libwebp-dev pkg-config unzip zlib1g-dev
- And for general setup: language-pack-en ccache git curl
$ schroot --user root --chroot gst
(gst)# sed -i "s/main$/main universe/g" /etc/apt/sources.list
(gst)# apt update
(gst)# apt upgrade
(gst)# apt --no-install-recommends --no-install-suggests install \
autotools-dev gnome-pkg-tools libtool libffi-dev libelf-dev \
libpcre3-dev desktop-file-utils libselinux1-dev libgamin-dev dbus \
dbus-x11 shared-mime-info libxml2-utils \
libssl-dev libreadline-dev libsqlite3-dev \
language-pack-en ccache git curl bison flex yasm python3-pip \
libasound2-dev libbz2-dev libcap-dev libdrm-dev libegl1-mesa-dev \
libfaad-dev libgl1-mesa-dev libgles2-mesa-dev libgmp-dev libgsl0-dev \
libjpeg-dev libmms-dev libmpg123-dev libogg-dev libopus-dev \
liborc-0.4-dev libpango1.0-dev libpng-dev libpulse-dev librtmp-dev \
libtheora-dev libtwolame-dev libvorbis-dev libvpx-dev libwebp-dev \
pkg-config unzip zlib1g-dev
Finally we create our installation prefix. In this case /opt/gst
to avoid the
contamination of /usr/local
and logout as root.
(gst)# mkdir -p /opt/gst
(gst)# chown vjaquez /opt/gst
(gst)# exit
compile FFmpeg 3.2 #
Now, let’s login again, but as the unprivileged user, to build the bundle,
starting with FFmpeg. Notice that we are using ccache
and building
out-of-source.
$ schroot --chroot gst
(gst)$ git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
(gst)$ cd ffmpeg
(gst)$ git checkout -b work n3.2.12
(gst)$ mkdir build
(gst)$ cd build
(gst)$ ../configure --disable-static --enable-shared \
--disable-programs --enable-pic --disable-doc --prefix=/opt/gst
(gst)$ PATH=/usr/lib/ccache/:${PATH} make -j8 install
compile glib 2.48 #
(gst)$ cd ~
(gst)$ git clone https://gitlab.gnome.org/GNOME/glib.git
(gst)$ cd glib
(gst)$ git checkout -b work origin/glib-2-48
(gst)$ mkdir mybuild
(gst)$ cd mybuild
(gst)$ ../autogen.sh --prefix=/opt/gst
(gst)$ PATH=/usr/lib/ccache/:${PATH} make -j8 install
install Python 3.5 #
Pyenv is a project that allows the automation of installing and executing, in the user home directory, multiple versions of Python.
(gst)$ curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
(gst)$ ~/.pyenv/bin/pyenv install 3.5.0
Install meson 0.50 #
We will install the last available version of meson in
the user home directory, that is why PATH
is extended and exported.
(gst)$ cd ~
(gst)$ ~/.pyenv/verion/3.5.0/pip3 install --user meson
(gst)$ export PATH=${HOME}/.local/bin:${PATH}
build GStreamer 1.14 #
PKG_CONFIG_PATH
is exported to expose the compiled versions of FFmpeg and
glib. Notice that the libraries are installed in /opt/lib
in order to avoid
the dispersion of pkg-config files.
(gst)$ cd ~/
(gst)$ export PKG_CONFIG_PATH=/opt/gst/lib/pkgconfig/
(gst)$ git clone https://gitlab.freedesktop.org/gstreamer/gst-build.git
(gst)$ cd gst-build
(gst)$ git checkout -b work origin/1.14
(gst)$ meson -Denable_python=false \
-Ddisable_gst_libav=false -Ddisable_gst_plugins_ugly=true \
-Ddisable_gst_plugins_bad=false -Ddisable_gst_devtools=true \
-Ddisable_gst_editing_services=true -Ddisable_rtsp_server=true \
-Ddisable_gst_omx=true -Ddisable_gstreamer_vaapi=true \
-Ddisable_gstreamer_sharp=true -Ddisable_introspection=true \
--prefix=/opt/gst build --libdir=lib
(gst)$ ninja -C build install
testing #
(gst)$ cd ~/
(gst)$ LD_LIBRARY_PATH=/opt/gst/lib \
GST_PLUGIN_SYSTEM_PATH=/opt/gst/lib/gstreamer-1.0/ \
/opt/gst/bin/gst-inspect-1.0
And the list of available elements shall be shown.
archive the bundle #
(gst)$ cd ~/
(gst)$ tar zpcvf gstreamer-1.14-x86_64-linux-gnu.tar.gz -C /opt ./gst
update your .travis.yml #
These are the packages you shall add to run this generated GStreamer bundle:
- libasound2-plugins
- libfaad2
- libfftw3-single3
- libjack-jackd2-0
- libmms0
- libmpg123-0
- libopus0
- liborc-0.4-0
- libpulsedsp
- libsamplerate0
- libspeexdsp1
- libtdb1
- libtheora0
- libtwolame0
- libwayland-egl1-mesa
- libwebp5
- libwebrtc-audio-processing-0
- liborc-0.4-dev
- pulseaudio
- pulseaudio-utils
And this is the before_install
and before_script
targets:
before_install:
- curl -L http://server.example/gstreamer-1.14-x86_64-linux-gnu.tar.gz | tar xz
- sed -i "s;prefix=/opt/gst;prefix=$PWD/gst;g" $PWD/gst/lib/pkgconfig/*.pc
- export PKG_CONFIG_PATH=$PWD/gst/lib/pkgconfig
- export GST_PLUGIN_SYSTEM_PATH=$PWD/gst/lib/gstreamer-1.0
- export GST_PLUGIN_SCANNER=$PWD/gst/libexec/gstreamer-1.0/gst-plugin-scanner
- export PATH=$PATH:$PWD/gst/bin
- export LD_LIBRARY_PATH=$PWD/gst/lib:$LD_LIBRARY_PATH
before_script:
- pulseaudio --start
- gst-inspect-1.0 | grep Total