Difference between revisions of "GStreamer In-Band Metadata for MPEG Transport Stream/Getting Started/Building natively"
Rgutierrez (talk | contribs) |
(→Compiling GStreamer) |
||
(18 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<noinclude> | <noinclude> | ||
− | {{GStreamer In-Band Metadata for MPEG Transport Stream/Head|previous=Getting Started|next=Getting Started/ | + | {{GStreamer In-Band Metadata for MPEG Transport Stream/Head|previous=Getting Started/Getting the code|next=Getting Started/Building the project|keywords=}} |
</noinclude> | </noinclude> | ||
Line 7: | Line 7: | ||
# Get gst-metadata source code | # Get gst-metadata source code | ||
# Install needed dependencies | # Install needed dependencies | ||
− | # Download | + | # Download GStreamer, gst-plugins-base and gst-plugins-bad source code |
− | # Patch | + | # Patch GStreamer and gst-plugins bad source code |
# Compile these three packages in order | # Compile these three packages in order | ||
# Overwrite system packages (Not required: Backup the files in case something goes wrong) | # Overwrite system packages (Not required: Backup the files in case something goes wrong) | ||
# Compile gst-metadata | # Compile gst-metadata | ||
− | # Install gst-metadata | + | # Install gst-metadata |
− | '''NOTE''': This assumes you already have GStreamer installed, if this is not the case, please proceede to install it in your system first. | + | {{Ambox |
+ | |type=notice | ||
+ | |small=left | ||
+ | |issue='''NOTE''': This assumes you already have GStreamer installed, if this is not the case, please proceede to install it in your system first. | ||
+ | |style=width:unset; | ||
+ | }} | ||
== Installation guide == | == Installation guide == | ||
Line 26: | Line 31: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | Then we set the GStreamer installation path from your system, please check the table below to set it: | + | Then we need to set the GStreamer installation path from your system, please check the table below to set it: |
− | + | <center> | |
<html> | <html> | ||
<table class='wikitable'> | <table class='wikitable'> | ||
Line 49: | Line 54: | ||
</table> | </table> | ||
</html> | </html> | ||
+ | </center> | ||
+ | |||
+ | In the case of the Jetson boards, you need to do it as below: | ||
− | |||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
− | + | export INSTALL_PATH=/usr/lib/aarch64-linux-gnu | |
− | export | ||
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 61: | Line 65: | ||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
− | export | + | cd ~ |
+ | export BUILD_DIR=`pwd`/gst-build # We will build all the packages inside of this folder | ||
+ | mkdir -p $BUILD_DIR | ||
+ | mkdir -p $BUILD_DIR/prefix | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === Download gst-metadata === | + | === {{Download}} Download gst-metadata === |
− | You can get the gst-metatada source code in place, for this you | + | You can get the gst-metatada source code in place, for this you can clone the repo inside BUILD_DIR directory with the next commands, or you can move the folder inside to it. |
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
cd $BUILD_DIR | cd $BUILD_DIR | ||
Line 83: | Line 90: | ||
libtool autopoint autoconf \ | libtool autopoint autoconf \ | ||
gettext yasm build-essential \ | gettext yasm build-essential \ | ||
− | autotools-dev dpkg-dev automake | + | autotools-dev dpkg-dev automake \ |
+ | libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 97: | Line 105: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === Download | + | === {{Download}} Download GStreamer source code === |
− | To start the building process, we need the source code of gstreamer, gst-plugins-base and gst-plugins-bad, for this we can run the following lines in bash: | + | To start the building process, we need the source code of gstreamer, gst-plugins-base and gst-plugins-bad, for this, we can run the following lines in bash: |
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
Line 112: | Line 120: | ||
mv $m-$BRANCH $m | mv $m-$BRANCH $m | ||
else | else | ||
− | echo "$m-$BRANCH source found!" | + | echo "$m-$BRANCH not source found!" |
fi | fi | ||
done | done | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | This will download each package and decompress it, then changes each name to remove the -$BRANCH from | + | This will download each package and decompress it, then changes each folder's name to remove the -$BRANCH from them. |
=== Patch gstreamer and gst-plugins bad === | === Patch gstreamer and gst-plugins bad === | ||
− | The next step before compilation of | + | The next step before compilation of GStreamer, is patching it, for this we should copy the patches and apply them in their respective package as follows: |
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
Line 155: | Line 163: | ||
cd $m | cd $m | ||
./autogen.sh --disable-gtk-doc --disable-tests --disable-nls && make -j8 | ./autogen.sh --disable-gtk-doc --disable-tests --disable-nls && make -j8 | ||
+ | export PKG_CONFIG_PATH=`pwd`/pkgconfig:$PKG_CONFIG_PATH | ||
+ | cd .. | ||
+ | done | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | If you run into the following error: | ||
+ | <pre> | ||
+ | error: #error This file requires compiler and library support for the ISO C++ 2011 standard. | ||
+ | This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options. | ||
+ | #error This file requires compiler and library support \ | ||
+ | </pre> | ||
+ | |||
+ | Please run the following commands instead | ||
+ | <syntaxhighlight lang=bash> | ||
+ | cd $BUILD_DIR | ||
+ | MODULES="gstreamer gst-plugins-base gst-plugins-bad" | ||
+ | for m in $MODULES | ||
+ | do | ||
+ | cd $m | ||
+ | ./autogen.sh --disable-gtk-doc --disable-tests --disable-nls && make CXXFLAGS=-std=c++11 -j8 | ||
export PKG_CONFIG_PATH=`pwd`/pkgconfig:$PKG_CONFIG_PATH | export PKG_CONFIG_PATH=`pwd`/pkgconfig:$PKG_CONFIG_PATH | ||
cd .. | cd .. | ||
Line 162: | Line 190: | ||
=== Overwrite GStreamer system packages === | === Overwrite GStreamer system packages === | ||
− | From the compilation stage, we need to copy some libraries into the system libraries, so for this is '''highly recommended''' to '''backup''' the original ones first just in case anything goes wrong: | + | From the compilation stage, we need to copy some libraries into the system libraries, so for this is '''highly recommended''' to '''backup''' the original ones first just in case anything goes wrong or you simply want to revert the changes: |
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
Line 176: | Line 204: | ||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
+ | cd $BUILD_DIR | ||
sudo cp $BUILD_DIR/gstreamer/libs/gst/base/.libs/libgstbase-1.0.so.0.$LIBRARY_VERSION.0 $INSTALL_PATH/libgstbase-1.0.so.0.$LIBRARY_VERSION.0 | sudo cp $BUILD_DIR/gstreamer/libs/gst/base/.libs/libgstbase-1.0.so.0.$LIBRARY_VERSION.0 $INSTALL_PATH/libgstbase-1.0.so.0.$LIBRARY_VERSION.0 | ||
sudo cp $BUILD_DIR/gst-plugins-bad/gst-libs/gst/codecparsers/.libs/libgstcodecparsers-1.0.so.0.$LIBRARY_VERSION.0 $INSTALL_PATH/libgstcodecparsers-1.0.so.0.$LIBRARY_VERSION.0 | sudo cp $BUILD_DIR/gst-plugins-bad/gst-libs/gst/codecparsers/.libs/libgstcodecparsers-1.0.so.0.$LIBRARY_VERSION.0 $INSTALL_PATH/libgstcodecparsers-1.0.so.0.$LIBRARY_VERSION.0 | ||
Line 184: | Line 213: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | == | + | === Compile gst-metadata === |
− | |||
− | |||
− | |||
− | gst-metadata | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Now that we have GStreamer patched, the compilation of gst-metadata is our next step, for this execute the following lines: | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
− | + | cd $BUILD_DIR | |
− | + | cd gst-metadata/src | |
− | + | ./autogen.sh | |
− | + | ./configure --prefix $BUILD_DIR/prefix/ | |
− | + | make all | |
− | + | make install | |
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | === Install gst-metadata === | |
− | + | Finally, we can install gst-metadata by copying it: | |
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
− | + | cd $BUILD_DIR | |
+ | sudo cp $BUILD_DIR/prefix/lib/gstreamer-1.0/libgstmeta.so $INSTALL_PATH/gstreamer-1.0/libgstmeta.so | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | == Verify installation == | |
− | + | At this point, it should be possible to inspect the meta element: | |
− | === | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | # Command | |
− | + | gst-inspect-1.0 meta | |
− | |||
− | |||
− | |||
− | + | # Output: | |
− | |||
− | |||
Plugin Details: | Plugin Details: | ||
Name meta | Name meta | ||
Description Elements used to send and receive metadata | Description Elements used to send and receive metadata | ||
− | Filename / | + | Filename /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstmeta.so |
− | Version 1. | + | Version 1.6.3 |
License Proprietary | License Proprietary | ||
Source module gst-plugin-meta | Source module gst-plugin-meta | ||
Line 327: | Line 254: | ||
metasrc: Metadata Source | metasrc: Metadata Source | ||
metasink: Metadata Sink | metasink: Metadata Sink | ||
+ | misbparser: MISB Parser | ||
− | + | 3 features: | |
− | +-- | + | +-- 3 elements |
</syntaxhighlight> | </syntaxhighlight> | ||
− | The plugin is ready to be used, | + | The plugin is ready to be used, check the examples section to use the meta plugin. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<noinclude> | <noinclude> | ||
− | {{GStreamer In-Band Metadata for MPEG Transport Stream/Foot|Getting Started|Getting Started/ | + | {{GStreamer In-Band Metadata for MPEG Transport Stream/Foot|Getting Started/Getting the code|Getting Started/Building the project}} |
</noinclude> | </noinclude> |
Latest revision as of 14:12, 22 June 2023
GStreamer In-Band Metadata for MPEG Transport Stream | |
---|---|
![]() | |
MPEG TS Metadata Basics | |
|
|
Getting Started | |
|
|
User Guide | |
|
|
Examples | |
|
|
FAQ | |
Contact Us |
Overview
In order to compile the meta plugin and install it directly, we need to patch some GStreamer libraries, so we need to:
- Get gst-metadata source code
- Install needed dependencies
- Download GStreamer, gst-plugins-base and gst-plugins-bad source code
- Patch GStreamer and gst-plugins bad source code
- Compile these three packages in order
- Overwrite system packages (Not required: Backup the files in case something goes wrong)
- Compile gst-metadata
- Install gst-metadata
![]() | NOTE: This assumes you already have GStreamer installed, if this is not the case, please proceede to install it in your system first. |
Installation guide
Before proceeding with each step, we are gonna need some general variables and steps to set up the building environment:
export BRANCH=$(gst-inspect-1.0 --version | awk 'NR==2 {print $2}') # This gets the version of GStreamer installed in the system
export BRANCH_PATCHES=$(echo $BRANCH | cut -d'.' -f 1-2) # This gets only the Major and Minor from the GStreamer version, we will need it later
export LIBRARY_VERSION=$(echo $BRANCH | awk -F "." '{f=$2; l=$3} END{if(l < 10)l=0l; print f l}') # This sets the Minor and Patch from the version in GStreamer as 1405 for example for version v1.14.5
Then we need to set the GStreamer installation path from your system, please check the table below to set it:
Platform | Path |
---|---|
Ubuntu 64-bits | /usr/lib/x86_64-linux-gnu |
RidgeRun's Embedded FS | -/usr |
Jetson TX1 TX2 Xavier Nano | /usr/lib/aarch64-linux-gnu |
In the case of the Jetson boards, you need to do it as below:
export INSTALL_PATH=/usr/lib/aarch64-linux-gnu
Then we can set our environment, you can change to any folder where you will like to start building the packages, for example, you can switch to home, this guide builds them inside the gst-build folder:
cd ~
export BUILD_DIR=`pwd`/gst-build # We will build all the packages inside of this folder
mkdir -p $BUILD_DIR
mkdir -p $BUILD_DIR/prefix
Download gst-metadata
You can get the gst-metatada source code in place, for this you can clone the repo inside BUILD_DIR directory with the next commands, or you can move the folder inside to it.
cd $BUILD_DIR
YOUR_NAME=your_name # Change this with your name in the repo
REPO_URL=https://gitlab.com/RidgeRun/orders/$YOUR_NAME/gst-metadata
git clone $REPO_URL
Install needed dependencies
This is the list of dependencies required to compile GStreamer
sudo apt-get install \
pkg-config bison flex git \
libglib2.0-dev liborc-0.4-dev \
libtool autopoint autoconf \
gettext yasm build-essential \
autotools-dev dpkg-dev automake \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
You may also need the development version of different libraries:
sudo apt-get install \
liborc-dev autopoint gtk-doc-tools libgstreamer1.0-dev \
libxv-dev libasound2-dev libtheora-dev libogg-dev libvorbis-dev \
libbz2-dev libv4l-dev libvpx-dev libjack-jackd2-dev libsoup2.4-dev libpulse-dev \
faad libfaad-dev libfaac-dev libgl1-mesa-dev libgles2-mesa-dev \
libx264-dev libmad0-dev
Download GStreamer source code
To start the building process, we need the source code of gstreamer, gst-plugins-base and gst-plugins-bad, for this, we can run the following lines in bash:
cd $BUILD_DIR
MODULES="gstreamer gst-plugins-base gst-plugins-bad"
for m in $MODULES
do
if [ ! -f "$m-$BRANCH.tar.xz" ]; then
wget http://gstreamer.freedesktop.org/src/$m/$m-$BRANCH.tar.xz
tar -xf $m-$BRANCH.tar.xz
mv $m-$BRANCH $m
else
echo "$m-$BRANCH not source found!"
fi
done
This will download each package and decompress it, then changes each folder's name to remove the -$BRANCH from them.
Patch gstreamer and gst-plugins bad
The next step before compilation of GStreamer, is patching it, for this we should copy the patches and apply them in their respective package as follows:
echo "Patching GStreamer core"
# Copy GStreamer patch to gstreamer folder
cd $BUILD_DIR
cp gst-metadata/extras/gstreamer-$BRANCH_PATCHES.x/fix-sparse-flag-setting-up.patch gstreamer/
# Apply GStreamer patch
cd gstreamer
git apply fix-sparse-flag-setting-up.patch
echo "Patching GStreamer Plugins Bad core"
# Copy GStreamer plugins bad patches to gstreamer-plugins-bad folder
cd $BUILD_DIR
cp gst-metadata/extras/gstreamer-$BRANCH_PATCHES.x/mpegtsmux-reference-clock-on-waiting-pad.patch gst-plugins-bad/
cp gst-metadata/extras/gstreamer-$BRANCH_PATCHES.x/mpegtsmux-meta-specific-pad-templates.patch gst-plugins-bad/
cp gst-metadata/extras/gstreamer-$BRANCH_PATCHES.x/tsmux-demux-update-klv-support.patch gst-plugins-bad/
# Apply GStreamer plugins bad patches
cd gst-plugins-bad
git apply mpegtsmux-reference-clock-on-waiting-pad.patch
git apply mpegtsmux-meta-specific-pad-templates.patch
git apply tsmux-demux-update-klv-support.patch
Compiling GStreamer
To compile GStreamer, is enough to get inside each of the packages' folder and compile inside, just as below:
cd $BUILD_DIR
MODULES="gstreamer gst-plugins-base gst-plugins-bad"
for m in $MODULES
do
cd $m
./autogen.sh --disable-gtk-doc --disable-tests --disable-nls && make -j8
export PKG_CONFIG_PATH=`pwd`/pkgconfig:$PKG_CONFIG_PATH
cd ..
done
If you run into the following error:
error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options. #error This file requires compiler and library support \
Please run the following commands instead
cd $BUILD_DIR
MODULES="gstreamer gst-plugins-base gst-plugins-bad"
for m in $MODULES
do
cd $m
./autogen.sh --disable-gtk-doc --disable-tests --disable-nls && make CXXFLAGS=-std=c++11 -j8
export PKG_CONFIG_PATH=`pwd`/pkgconfig:$PKG_CONFIG_PATH
cd ..
done
Overwrite GStreamer system packages
From the compilation stage, we need to copy some libraries into the system libraries, so for this is highly recommended to backup the original ones first just in case anything goes wrong or you simply want to revert the changes:
sudo cp $INSTALL_PATH/libgstbase-1.0.so.0.$LIBRARY_VERSION.0 $INSTALL_PATH/libgstbase-1.0.so.0.$LIBRARY_VERSION.0.bk
sudo cp $INSTALL_PATH/libgstcodecparsers-1.0.so.0.$LIBRARY_VERSION.0 $INSTALL_PATH/libgstcodecparsers-1.0.so.0.$LIBRARY_VERSION.0.bk
sudo cp $INSTALL_PATH/libgstmpegts-1.0.so.0.$LIBRARY_VERSION.0 $INSTALL_PATH/libgstmpegts-1.0.so.0.$LIBRARY_VERSION.0.bk
sudo cp $INSTALL_PATH/gstreamer-1.0/libgstmpegpsdemux.so $INSTALL_PATH/gstreamer-1.0/libgstmpegpsdemux.so.bk
sudo cp $INSTALL_PATH/gstreamer-1.0/libgstmpegtsmux.so $INSTALL_PATH/gstreamer-1.0/libgstmpegtsmux.so.bk
sudo cp $INSTALL_PATH/gstreamer-1.0/libgstmpegtsdemux.so $INSTALL_PATH/gstreamer-1.0/libgstmpegtsdemux.so.bk
Then we can update them by installing the ones we just compiled:
cd $BUILD_DIR
sudo cp $BUILD_DIR/gstreamer/libs/gst/base/.libs/libgstbase-1.0.so.0.$LIBRARY_VERSION.0 $INSTALL_PATH/libgstbase-1.0.so.0.$LIBRARY_VERSION.0
sudo cp $BUILD_DIR/gst-plugins-bad/gst-libs/gst/codecparsers/.libs/libgstcodecparsers-1.0.so.0.$LIBRARY_VERSION.0 $INSTALL_PATH/libgstcodecparsers-1.0.so.0.$LIBRARY_VERSION.0
sudo cp $BUILD_DIR/gst-plugins-bad/gst-libs/gst/mpegts/.libs/libgstmpegts-1.0.so.0.$LIBRARY_VERSION.0 $INSTALL_PATH/libgstmpegts-1.0.so.0.$LIBRARY_VERSION.0
sudo cp $BUILD_DIR/gst-plugins-bad/gst/mpegdemux/.libs/libgstmpegpsdemux.so $INSTALL_PATH/gstreamer-1.0/libgstmpegpsdemux.so
sudo cp $BUILD_DIR/gst-plugins-bad/gst/mpegtsmux/.libs/libgstmpegtsmux.so $INSTALL_PATH/gstreamer-1.0/libgstmpegtsmux.so
sudo cp $BUILD_DIR/gst-plugins-bad/gst/mpegtsdemux/.libs/libgstmpegtsdemux.so $INSTALL_PATH/gstreamer-1.0/libgstmpegtsdemux.so
Compile gst-metadata
Now that we have GStreamer patched, the compilation of gst-metadata is our next step, for this execute the following lines:
cd $BUILD_DIR
cd gst-metadata/src
./autogen.sh
./configure --prefix $BUILD_DIR/prefix/
make all
make install
Install gst-metadata
Finally, we can install gst-metadata by copying it:
cd $BUILD_DIR
sudo cp $BUILD_DIR/prefix/lib/gstreamer-1.0/libgstmeta.so $INSTALL_PATH/gstreamer-1.0/libgstmeta.so
Verify installation
At this point, it should be possible to inspect the meta element:
# Command
gst-inspect-1.0 meta
# Output:
Plugin Details:
Name meta
Description Elements used to send and receive metadata
Filename /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstmeta.so
Version 1.6.3
License Proprietary
Source module gst-plugin-meta
Binary package RidgeRun elements
Origin URL http://www.ridgerun.com
metasrc: Metadata Source
metasink: Metadata Sink
misbparser: MISB Parser
3 features:
+-- 3 elements
The plugin is ready to be used, check the examples section to use the meta plugin.