Difference between revisions of "GStreamer In-Band Metadata for MPEG Transport Stream/Getting Started/Building the project"

From RidgeRun Developer Connection
Jump to: navigation, search
(Enabling faster metadata)
m (Verify)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<noinclude>
 
<noinclude>
{{GStreamer In-Band Metadata for MPEG Transport Stream/Head|previous=Getting Started/Getting the code|next=User Guide|keywords=}}
+
{{GStreamer In-Band Metadata for MPEG Transport Stream/Head|previous=Getting Started/Building natively|next=User Guide|keywords=}}
 
</noinclude>
 
</noinclude>
  
 
__TOC__
 
__TOC__
  
=Overview=
+
==Overview==
This page provides a guide to install GstMetadata.
+
This page provides a guide to installing GstMetadata.
  
 
This plugin requires some patches on the GStreamer standard plugins to properly handle the metadata.
 
This plugin requires some patches on the GStreamer standard plugins to properly handle the metadata.
Line 16: Line 16:
 
Follow the instructions on the '''Dependencies''' and '''Prerequisites''' sections to install the patches on the custom environment.
 
Follow the instructions on the '''Dependencies''' and '''Prerequisites''' sections to install the patches on the custom environment.
  
=Dependencies=
+
==Dependencies==
  
 
[https://www.ridgerun.com/gstreamer-inband-metada-support GstMetaData] has the following dependencies:
 
[https://www.ridgerun.com/gstreamer-inband-metada-support GstMetaData] has the following dependencies:
Line 42: Line 42:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=Prerequisites=
+
==Prerequisites==
 
An easy procedure to install a custom environment is available at [https://developer.ridgerun.com/wiki/index.php?title=GStreamer_In-Band_Metadata_for_MPEG_Transport_Stream/Getting_Started/Evaluating_the_project Evaluating the project] under the section [https://developer.ridgerun.com/wiki/index.php?title=GStreamer_In-Band_Metadata_for_MPEG_Transport_Stream/Getting_Started/Evaluating_the_project#Building_the_alternative_GStreamer_environment Building the alternative GStreamer environment].
 
An easy procedure to install a custom environment is available at [https://developer.ridgerun.com/wiki/index.php?title=GStreamer_In-Band_Metadata_for_MPEG_Transport_Stream/Getting_Started/Evaluating_the_project Evaluating the project] under the section [https://developer.ridgerun.com/wiki/index.php?title=GStreamer_In-Band_Metadata_for_MPEG_Transport_Stream/Getting_Started/Evaluating_the_project#Building_the_alternative_GStreamer_environment Building the alternative GStreamer environment].
  
 
When the custom environment is ready, follow the instructions below to apply the patches. In case you want to use the plugin in the GStreamer version installed in your system, create an alternative environment with the same GStreamer version.
 
When the custom environment is ready, follow the instructions below to apply the patches. In case you want to use the plugin in the GStreamer version installed in your system, create an alternative environment with the same GStreamer version.
  
=Install purchased gst-metadata source code =
+
==Install purchased gst-metadata source code ==
 
The first step is setting the required environment variables to place the code in the correct folder.
 
The first step is setting the required environment variables to place the code in the correct folder.
  
Line 55: Line 55:
 
GSTENV=$DEVDIR/$BRANCH
 
GSTENV=$DEVDIR/$BRANCH
 
</syntaxhighlight>
 
</syntaxhighlight>
 
  
 
Then you can get the gst-metatada source code in place, for this you should clone the repo:
 
Then you can get the gst-metatada source code in place, for this you should clone the repo:
Line 65: Line 64:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==Patches Installation==
+
===Patches Installation===
  
 
Enter the custom GStreamer directory
 
Enter the custom GStreamer directory
Line 90: Line 89:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Patch for GStreamer ===
+
==== Patch for GStreamer ====
  
 
Change to custom GStreamer version
 
Change to custom GStreamer version
Line 97: Line 96:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
'''NOTE''': If you are using a tag in the form 1.y.x for the '''BRANCH''' variable, use '''BRANCH'''=1.y for copying the patches from the gst-metadata/extras/ folder
+
{{Ambox
 +
|type=notice
 +
|small=left
 +
|issue=If you are using a tag in the form 1.y.x for the '''BRANCH''' variable, use '''BRANCH=1.y''' for copying the patches from the gst-metadata/extras/ folder.
 +
|style=width:unset;
 +
}}
 +
 
 
<syntaxhighlight lang=bash>
 
<syntaxhighlight lang=bash>
 
BRANCH_PATCH=1.16
 
BRANCH_PATCH=1.16
 
</syntaxhighlight>
 
</syntaxhighlight>
 
  
 
Copy and apply patch file
 
Copy and apply patch file
Line 110: Line 114:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Patch for GStreamer plugins bad ===
+
==== Patch for GStreamer plugins bad ====
  
 
Change to custom GStreamer version
 
Change to custom GStreamer version
Line 117: Line 121:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
'''NOTE''': If you are using a tag in the form 1.y.x for the '''BRANCH''' variable, use '''BRANCH'''=1.y for copying the patches from the gst-metadata/extras/ folder
+
{{Ambox
 +
|type=notice
 +
|small=left
 +
|issue=If you are using a tag in the form 1.y.x for the '''BRANCH''' variable, use '''BRANCH'''=1.y for copying the patches from the gst-metadata/extras/ folder.
 +
|style=width:unset;
 +
}}
 +
 
 
<syntaxhighlight lang=bash>
 
<syntaxhighlight lang=bash>
 
BRANCH_PATCH=1.16
 
BRANCH_PATCH=1.16
Line 133: Line 143:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Recompile plugins ===
+
==== Recompile plugins ====
 
Return to DEVDIR and enter the custom Gstreamer environment
 
Return to DEVDIR and enter the custom Gstreamer environment
 
<syntaxhighlight lang=bash>
 
<syntaxhighlight lang=bash>
Line 151: Line 161:
 
At this point, the patches are applied in the custom environment
 
At this point, the patches are applied in the custom environment
  
==Compile and Install plugin==
+
===Compile and Install plugin===
  
===In Custom GStreamer Environment===
+
====In Custom GStreamer Environment====
 
Make sure that you are in the custom GStreamer environment.
 
Make sure that you are in the custom GStreamer environment.
  
Line 179: Line 189:
 
Now, GstMetadata is installed in the custom GStreamer environment.
 
Now, GstMetadata is installed in the custom GStreamer environment.
  
===In GStreamer's Default Path===
+
====In GStreamer's Default Path====
 
This section is in case of installing the plugin into a '''GStreamer's default path on the system''', use the arguments below according to the target platform
 
This section is in case of installing the plugin into a '''GStreamer's default path on the system''', use the arguments below according to the target platform
  
Line 283: Line 293:
 
Now the binaries and GtsMetadata are installed in the system.
 
Now the binaries and GtsMetadata are installed in the system.
  
=Verify=
+
==Verify==
 
The plugin installation can be verified by running:
 
The plugin installation can be verified by running:
 
<syntaxhighlight lang='bash'>
 
<syntaxhighlight lang='bash'>
Line 309: Line 319:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
= Enabling faster metadata =
+
=== Enabling faster metadata ===
  
 
Enabling faster metadata will change the <code>metasrc</code> period capacity from seconds to milliseconds.
 
Enabling faster metadata will change the <code>metasrc</code> period capacity from seconds to milliseconds.
Line 315: Line 325:
 
To write faster metadata with <code>metasrc</code> element from the metadata plugin, gst-plugin-bad needs an extra patch over the ones already needed to make gst-metadata work.
 
To write faster metadata with <code>metasrc</code> element from the metadata plugin, gst-plugin-bad needs an extra patch over the ones already needed to make gst-metadata work.
  
== Patch process ==
+
=== Patch process ===
  
=== Checking environment variables ===
+
==== Checking environment variables ====
  
 
* First, make sure you have already followed the steps from the original instructions to make gst-metadata work. You should have the environment variables set-up:
 
* First, make sure you have already followed the steps from the original instructions to make gst-metadata work. You should have the environment variables set-up:
Line 335: Line 345:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Applying patch for gst-plugin-bad ===
+
==== Applying patch for gst-plugin-bad ====
  
 
* Now, copy the <code>faster-metadata-support.patch</code> from the patches folder into the source directory of gst-plugin-bad:
 
* Now, copy the <code>faster-metadata-support.patch</code> from the patches folder into the source directory of gst-plugin-bad:
Line 352: Line 362:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Applying patch for gst-metadata ===
+
==== Applying patch for gst-metadata ====
  
 
* Apply the patch needed by gst-metadata to enable sending information in milliseconds:
 
* Apply the patch needed by gst-metadata to enable sending information in milliseconds:
Line 364: Line 374:
  
 
<noinclude>
 
<noinclude>
{{GStreamer In-Band Metadata for MPEG Transport Stream/Foot|Getting Started/Getting the code|User Guide}}
+
{{GStreamer In-Band Metadata for MPEG Transport Stream/Foot|Getting Started/Building natively|User Guide}}
 
</noinclude>
 
</noinclude>

Latest revision as of 13:46, 6 March 2022


Previous: Getting Started/Building natively Index Next: User Guide





Overview

This page provides a guide to installing GstMetadata.

This plugin requires some patches on the GStreamer standard plugins to properly handle the metadata. There are 2 possible scenarios for the installation:

  • On GStreamer version installed in your system
  • On custom GStreamer environment

For both cases, a custom GStreamer environment is needed to install the patches. Follow the instructions on the Dependencies and Prerequisites sections to install the patches on the custom environment.

Dependencies

GstMetaData has the following dependencies:

  • gtk-doc-tools
  • libgstreamer1.0-dev
  • libgstreamer-plugins-base1.0-dev

Make sure you have the following GStreamer elements:

  • videotestsrc
  • xvimagesink
  • videoconvert
  • tsparse
  • tsdemux
  • mpegtsmux
  • h264parse
  • x264enc
  • avdec_h264

In Ubuntu 16.04 and 18.04 based systems, you may install the dependencies with the following command:

sudo apt-get install -y gtk-doc-tools libgtk2.0-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libmp3lame-dev

Prerequisites

An easy procedure to install a custom environment is available at Evaluating the project under the section Building the alternative GStreamer environment.

When the custom environment is ready, follow the instructions below to apply the patches. In case you want to use the plugin in the GStreamer version installed in your system, create an alternative environment with the same GStreamer version.

Install purchased gst-metadata source code

The first step is setting the required environment variables to place the code in the correct folder.

DEVDIR=~/Gst-versions
BRANCH="1.16.0"        #Example version used in the guide
GSTENV=$DEVDIR/$BRANCH

Then you can get the gst-metatada source code in place, for this you should clone the repo:

CLIENT_NAME=client # Change this with your client name in the repo
REPO_URL=https://gitlab.com/RidgeRun/orders/$CLIENT_NAME/gst-metadata
cd $GSTENV
git clone $REPO_URL

Patches Installation

Enter the custom GStreamer directory

cd $GSTENV

The directory should look as follows

ls $GSTENV

Expected output:

~/Gst-versions/1.16$ ls $GSTENV
gst-libav  gst-metadata  gst-plugins-bad  gst-plugins-base  gst-plugins-good  gst-plugins-ugly  gstreamer  prefix

If gst-metadata is not present here, copy the folder from where you cloned it:

cd $GSTENV
GSTMETADATA_LOCATION=~/gst-metadata/
cp $GSTMETADATA_LOCATION gst-metadata -r

Patch for GStreamer

Change to custom GStreamer version

cd $GSTENV
BRANCH_PATCH=1.16

Copy and apply patch file

cp gst-metadata/extras/gstreamer-$BRANCH_PATCH.x/fix-sparse-flag-setting-up.patch gstreamer/
cd gstreamer
git apply fix-sparse-flag-setting-up.patch

Patch for GStreamer plugins bad

Change to custom GStreamer version

cd $GSTENV
BRANCH_PATCH=1.16

Copy and apply patches

cp gst-metadata/extras/gstreamer-$BRANCH_PATCH.x/mpegtsmux-reference-clock-on-waiting-pad.patch gst-plugins-bad/
cp gst-metadata/extras/gstreamer-$BRANCH_PATCH.x/mpegtsmux-meta-specific-pad-templates.patch gst-plugins-bad/
cp gst-metadata/extras/gstreamer-$BRANCH_PATCH.x/tsmux-demux-update-klv-support.patch gst-plugins-bad/
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

Recompile plugins

Return to DEVDIR and enter the custom Gstreamer environment

cd $DEVDIR
./gst-$BRANCH

Recompile plugins

for module in `echo gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav`; do
    cd $module
    ./autogen.sh --disable-gtk-doc --disable-tests --disable-nls && make -j8
    cd -
done

At this point, the patches are applied in the custom environment

Compile and Install plugin

In Custom GStreamer Environment

Make sure that you are in the custom GStreamer environment.

Create the installation folder for GstMetadata

mkdir -p prefix/lib/gstreamer-1.0

Run the following commands to compile and install the plugin in the custom GStreamer environment.

cd gst-metadata/src
./autogen.sh
./configure --prefix $(realpath ../../prefix/)
make all
make install

Let's include the prefix path into the GST_PLUGIN_PATH environmental variable to load the meta plugin.

In case that after loading the custom GStreamer environment the meta plugin is not present, load the prefix path into the GST_PLUGIN_PATH environmental variable, in this guide $(realpath ../../prefix/) represents /home/gfallas/Gst-versions/1.8/prefix

export GST_PLUGIN_PATH=$(realpath ../../prefix/):$GST_PLUGIN_PATH

Now, GstMetadata is installed in the custom GStreamer environment.

In GStreamer's Default Path

This section is in case of installing the plugin into a GStreamer's default path on the system, use the arguments below according to the target platform

The configuration stage depend on the target system, use table below as reference:

System Configure Option
Ubuntu 64 bits --prefix /usr/ --libdir /usr/lib/x86_64-linux-gnu/
RidgeRun's Embedded FS --prefix /usr/
Jetson TX1 TX2 Xavier --prefix /usr/ --libdir /usr/lib/aarch64-linux-gnu/
Table 1. Platform configuration options

Run the next commands to configure and compile the plugin

cd gst-plugin-meta-1.0/src
./autogen
./configure $OPTIONS # CHOOSE THE APPROPRIATE CONFIGURATION FROM THE TABLE ABOVE
make all
sudo make install

Now, you will need the modified binaries from the custom GStreamer environment, this only applies when the GStreamer version and the custom version are the same.

The installation path depends on the target platform:

Platform Path
Ubuntu 64-bits /usr/lib/x86_64-linux-gnu
RidgeRun's Embedded FS -/usr
Jetson TX1 TX2 Xavier /usr/lib/aarch64-linux-gnu
Table 1. GStreamer's default path

Before installing the binaries in the system, it is highly recommended to backup the default files: As example, for an x86_64 installation the GStreamer's path is /usr/lib/x86_64-linux-gnu/

MY_PATH=/usr/lib/x86_64-linux-gnu
VERSION=1602

sudo cp $MY_PATH/libgstbase-1.0.so.0.$VERSION.0 $MY_PATH/libgstbase-1.0.so.0.$VERSION.0.bk
sudo cp $MY_PATH/libgstcodecparsers-1.0.so.0.$VERSION.0 $MY_PATH/libgstcodecparsers-1.0.so.0.$VERSION.0.bk
sudo cp $MY_PATH/libgstmpegts-1.0.so.0.$VERSION.0 $MY_PATH/libgstmpegts-1.0.so.0.$VERSION.0.bk
sudo cp $MY_PATH/gstreamer-1.0/libgstmpegpsdemux.so $MY_PATH/gstreamer-1.0/libgstmpegpsdemux.so.bk
sudo cp $MY_PATH/gstreamer-1.0/libgstmpegtsmux.so $MY_PATH/gstreamer-1.0/libgstmpegtsmux.so.bk
sudo cp $MY_PATH/gstreamer-1.0/libgstmpegtsdemux.so $MY_PATH/gstreamer-1.0/libgstmpegtsdemux.so.bk

Then, copy the required libraries from the custom GStreamer environment. Remember to check the path according to the platform and the gstmetadata library location inside the prefix folder according to the tables above to copy it properly.

MY_PATH=/usr/lib/x86_64-linux-gnu
VERSION=1602

cd $GSTENV
sudo cp $GSTENV/prefix/lib/gstreamer-1.0/libgstmeta.so $MY_PATH/gstreamer-1.0/libgstmeta.so

sudo cp $GSTENV/gstreamer/libs/gst/base/.libs/libgstbase-1.0.so.0.$VERSION.0 $MY_PATH/libgstbase-1.0.so.0.$VERSION.0
sudo cp $GSTENV/gst-plugins-bad/gst-libs/gst/codecparsers/.libs/libgstcodecparsers-1.0.so.0.$VERSION.0 $MY_PATH/libgstcodecparsers-1.0.so.0.$VERSION.0
sudo cp $GSTENV/gst-plugins-bad/gst-libs/gst/mpegts/.libs/libgstmpegts-1.0.so.0.$VERSION.0 $MY_PATH/libgstmpegts-1.0.so.0.$VERSION.0

sudo cp $GSTENV/gst-plugins-bad/gst/mpegdemux/.libs/libgstmpegpsdemux.so $MY_PATH/gstreamer-1.0/libgstmpegpsdemux.so
sudo cp $GSTENV/gst-plugins-bad/gst/mpegtsmux/.libs/libgstmpegtsmux.so $MY_PATH/gstreamer-1.0/libgstmpegtsmux.so
sudo cp $GSTENV/gst-plugins-bad/gst/mpegtsdemux/.libs/libgstmpegtsdemux.so $MY_PATH/gstreamer-1.0/libgstmpegtsdemux.so

Now the binaries and GtsMetadata are installed in the system.

Verify

The plugin installation can be verified by running:

gst-inspect-1.0 meta

Expected output:

Plugin Details:
Name meta
Description Elements used to send and receive metadata
Filename /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstmeta.so
Version 1.6.0
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

Enabling faster metadata

Enabling faster metadata will change the metasrc period capacity from seconds to milliseconds.

To write faster metadata with metasrc element from the metadata plugin, gst-plugin-bad needs an extra patch over the ones already needed to make gst-metadata work.

Patch process

Checking environment variables

  • First, make sure you have already followed the steps from the original instructions to make gst-metadata work. You should have the environment variables set-up:
export DEVDIR=~/Gst-versions
export BRANCH="1.14.5" #Example version used in the guide
export GSTENV=$DEVDIR/$BRANCH
export BRANCH_PATCH=1.14 #Example version used in the guide for the patch directory
  • And in $GSTENV, the following files should exist:
ls $GSTENV
gst-libav  gst-metadata  gst-plugins-bad  gst-plugins-base  gst-plugins-good  gst-plugins-ugly  gstreamer  prefix

Applying patch for gst-plugin-bad

  • Now, copy the faster-metadata-support.patch from the patches folder into the source directory of gst-plugin-bad:
cd $GSTENV
cp extras/gstreamer-$BRANCH_PATCH.x/faster-metadata-support.patch gst-plugins-bad/
cd gst-plugins-bad
git apply faster-metadata-support.patch
  • And compile it again:
./autogen.sh --disable-gtk-doc --disable-tests --disable-nls && make -j8

Applying patch for gst-metadata

  • Apply the patch needed by gst-metadata to enable sending information in milliseconds:
cd $GSTENV/gst-metadata
git apply extras/gstreamer-$BRANCH_PATCH.x/metasrc-period-from-s-to-ms.patch


Previous: Getting Started/Building natively Index Next: User Guide