Compile gstreamer on Jetson TX1 and TX2: Difference between revisions

From RidgeRun Developer Wiki
mNo edit summary
mNo edit summary
 
Line 19: Line 19:
1. Get source code
1. Get source code


<pre>
<syntaxhighlight lang="bash">
VERSION=1.14.5
VERSION=1.14.5


Line 31: Line 31:
wget https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-$VERSION.tar.xz --no-check-certificate
wget https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-$VERSION.tar.xz --no-check-certificate
for a in `ls -1 *.tar.*`; do tar -xf $a; done
for a in `ls -1 *.tar.*`; do tar -xf $a; done
</pre>
</syntaxhighlight>


2. Install dependencies
2. Install dependencies


<pre>
<syntaxhighlight lang="bash">
sudo apt-get install build-essential dpkg-dev flex bison autotools-dev automake \
sudo apt-get install build-essential dpkg-dev flex bison autotools-dev automake \
autopoint libtool gtk-doc-tools libgstreamer1.0-dev \
autopoint libtool gtk-doc-tools libgstreamer1.0-dev \
Line 43: Line 43:
libx264-dev libmad0-dev
libx264-dev libmad0-dev


</pre>
</syntaxhighlight>


3. Export PKG_CONFIG_PATH and LD_LIBRARY_PATH
3. Export PKG_CONFIG_PATH and LD_LIBRARY_PATH


<pre>
<syntaxhighlight lang="bash">
export PKG_CONFIG_PATH=/home/$USER/gst_$VERSION/out/lib/pkgconfig
export PKG_CONFIG_PATH=/home/$USER/gst_$VERSION/out/lib/pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/aarch64-linux-gnu/pkgconfig  
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/aarch64-linux-gnu/pkgconfig  
export LD_LIBRARY_PATH=/home/$USER/gst_$VERSION/out/lib/
export LD_LIBRARY_PATH=/home/$USER/gst_$VERSION/out/lib/
</pre>
</syntaxhighlight>


4. Build
4. Build
<pre>
<syntaxhighlight lang="bash">
VERSION=1.14.5
VERSION=1.14.5
NPROC=$(nproc)
NPROC=$(nproc)
Line 96: Line 96:
cd ..
cd ..


</pre>
</syntaxhighlight>


5. Export LD_LIBRARY_PATH
5. Export LD_LIBRARY_PATH


<pre>
<syntaxhighlight lang="bash">
VERSION=1.14.5
VERSION=1.14.5
export LD_LIBRARY_PATH=/home/$USER/gst_$VERSION/out/lib/
export LD_LIBRARY_PATH=/home/$USER/gst_$VERSION/out/lib/
</pre>
</syntaxhighlight>


6. Copy the NVIDIA libraries
6. Copy the NVIDIA libraries


<pre>
<syntaxhighlight lang="bash">
ls /usr/lib/aarch64-linux-gnu/gstreamer-1.0 | grep nv
ls /usr/lib/aarch64-linux-gnu/gstreamer-1.0 | grep nv
libgstaudioconvert.so
libgstaudioconvert.so
Line 124: Line 124:
cd ~/gst_$VERSION
cd ~/gst_$VERSION


</pre>
</syntaxhighlight>


== Steps to patch GStreamer to support RAW10 ==
== Steps to patch GStreamer to support RAW10 ==
Line 131: Line 131:
1- Apply the following patch to the gst-plugins good:
1- Apply the following patch to the gst-plugins good:


<pre>
<syntaxhighlight lang="bash">
mkdir patches
mkdir patches
cd patches
cd patches
echo 0001-Add-Bayer10-V4l2-support.patch > series
echo 0001-Add-Bayer10-V4l2-support.patch > series
</pre>
</syntaxhighlight>




Create a file called: '''patches/0001-Add-Bayer10-V4l2-support.patch''' with the following contents:
Create a file called: '''patches/0001-Add-Bayer10-V4l2-support.patch''' with the following contents:


<pre>
<syntaxhighlight lang="bash">
diff --git a/gst_1.14.5/gst-plugins-good-1.14.5/sys/v4l2/gstv4l2object.c b/gst_1.14.5/gst-plugins-good-1.14.5/sys/v4l2/gstv4l2object.c
diff --git a/gst_1.14.5/gst-plugins-good-1.14.5/sys/v4l2/gstv4l2object.c b/gst_1.14.5/gst-plugins-good-1.14.5/sys/v4l2/gstv4l2object.c
index 124c778..8fdcc42 100644
index 124c778..8fdcc42 100644
Line 217: Line 217:
     } else if (g_str_equal (mimetype, "video/x-sonix")) {
     } else if (g_str_equal (mimetype, "video/x-sonix")) {
       fourcc = V4L2_PIX_FMT_SN9C10X;
       fourcc = V4L2_PIX_FMT_SN9C10X;
</pre>
</syntaxhighlight>


Apply the patch
Apply the patch


<pre>
<syntaxhighlight lang="bash">
cd ..
cd ..
quilt push
quilt push
</pre>
</syntaxhighlight>


2- Recompile the plugins good:
2- Recompile the plugins good:
<pre>
<syntaxhighlight lang="bash">


cd gst-plugins-good-$VERSION
cd gst-plugins-good-$VERSION
./configure --prefix=/home/$USER/gst_$VERSION/out ; time make ; make install ;
./configure --prefix=/home/$USER/gst_$VERSION/out ; time make ; make install ;


</pre>
</syntaxhighlight>


3- Export the libraries:
3- Export the libraries:
<pre>
<syntaxhighlight lang="bash">
VERSION=1.14.5
VERSION=1.14.5
export LD_LIBRARY_PATH=/home/$USER/gst_$VERSION/out/lib/
export LD_LIBRARY_PATH=/home/$USER/gst_$VERSION/out/lib/
</pre>
</syntaxhighlight>


4- Capturing from a sensor using RAW10 in either rggb,gbrg,grbg ot bggr pixel order using gstreamer should be posible now, try running the following example pipeline:
4- Capturing from a sensor using RAW10 in either rggb,gbrg,grbg ot bggr pixel order using gstreamer should be posible now, try running the following example pipeline:


<pre>
<syntaxhighlight lang="bash">
gst-launch-1.0 -vvv v4l2src num-buffers=10  ! "video/x-bayer,width=1920,height=1080 format=bggr" ! fakesink -v
gst-launch-1.0 -vvv v4l2src num-buffers=10  ! "video/x-bayer,width=1920,height=1080 format=bggr" ! fakesink -v


gst-launch-1.0 -vvv v4l2src num-buffers=10  ! "video/x-bayer,width=1920,height=1080,format=bggr,framerate=30/1" ! multifilesink location=test%d.raw  -v
gst-launch-1.0 -vvv v4l2src num-buffers=10  ! "video/x-bayer,width=1920,height=1080,format=bggr,framerate=30/1" ! multifilesink location=test%d.raw  -v
</pre>
</syntaxhighlight>


== See also ==
== See also ==

Latest revision as of 11:40, 22 November 2024






Introduction to compile GStreamer on Jetson TX1, TX2, and Nano

Instructions to compile GStreamer on Jetson TX1, Jetson TX2, and Nano. The main steps were taken from the Tegra X1/Tegra Linux Driver package multimedia user guide document These steps were run on Jetson TX1, TX2, and Nano.

Steps to compile GStreamer on Jetson TX1, TX2, and Nano

1. Get source code

VERSION=1.14.5

mkdir ~/gst_$VERSION
cd ~/gst_$VERSION

wget https://gstreamer.freedesktop.org/src/gst-plugins-base/gst-plugins-base-$VERSION.tar.xz --no-check-certificate
wget https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-$VERSION.tar.xz --no-check-certificate
wget https://gstreamer.freedesktop.org/src/gst-plugins-ugly/gst-plugins-ugly-$VERSION.tar.xz --no-check-certificate
wget https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-$VERSION.tar.xz --no-check-certificate
wget https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-$VERSION.tar.xz --no-check-certificate
for a in `ls -1 *.tar.*`; do tar -xf $a; done

2. Install dependencies

sudo apt-get install build-essential dpkg-dev flex bison autotools-dev automake \
autopoint libtool 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 libgl1-mesa-dev libgles2-mesa-dev \
libx264-dev libmad0-dev

3. Export PKG_CONFIG_PATH and LD_LIBRARY_PATH

export PKG_CONFIG_PATH=/home/$USER/gst_$VERSION/out/lib/pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/aarch64-linux-gnu/pkgconfig 
export LD_LIBRARY_PATH=/home/$USER/gst_$VERSION/out/lib/

4. Build

VERSION=1.14.5
NPROC=$(nproc)
mkdir -p /home/$USER/gst_$VERSION/out

cd /home/$USER/gst_$VERSION

#Gstreamer - 3 minutes compiling
cd gstreamer-$VERSION
./configure --prefix=/home/$USER/gst_$VERSION/out
make -j$NPROC 
make install 
cd ..

#Base
cd gst-plugins-base-$VERSION
./configure --prefix=/home/$USER/gst_$VERSION/out
time make -j$NPROC
make install
cd ..

#Good - 8 minutes
cd gst-plugins-good-$VERSION
./configure --prefix=/home/$USER/gst_$VERSION/out
time make -j$NPROC
make install
cd ..

#Bad
cd gst-plugins-bad-$VERSION
./configure --prefix=/home/$USER/gst_$VERSION/out
time make -j$NPROC
make install
cd ..

# Ugly
cd gst-plugins-ugly-$VERSION
./configure --prefix=/home/$USER/gst_$VERSION/out
time make -j$NPROC
make install
cd ..

5. Export LD_LIBRARY_PATH

VERSION=1.14.5
export LD_LIBRARY_PATH=/home/$USER/gst_$VERSION/out/lib/

6. Copy the NVIDIA libraries

ls /usr/lib/aarch64-linux-gnu/gstreamer-1.0 | grep nv
libgstaudioconvert.so
libgstnvcamera.so
libgstnveglglessink.so
libgstnveglstreamsrc.so
libgstnvegltransform.so
libgstnvivafilter.so
libgstnvvidconv.so
libgstnvvideosink.so
libgstvideoconvert.so
libnvgstjpeg.so

cd /usr/lib/aarch64-linux-gnu/gstreamer-1.0/
cp libgstnv* libnvgst* libgstomx.so ~/gst_$VERSION/out/lib/gstreamer-1.0/
cd ~/gst_$VERSION

Steps to patch GStreamer to support RAW10

The GStreamer version distributed with Jetpack doesn't support bayer RAW10 only RAW8 so gstreamer needs to be patched in order to capture using v4l2src. Since the plugins were already recompiled you can patch v4l2src in your working dir to get it working with RAW10 following the next steps.

1- Apply the following patch to the gst-plugins good:

mkdir patches
cd patches
echo 0001-Add-Bayer10-V4l2-support.patch > series


Create a file called: patches/0001-Add-Bayer10-V4l2-support.patch with the following contents:

diff --git a/gst_1.14.5/gst-plugins-good-1.14.5/sys/v4l2/gstv4l2object.c b/gst_1.14.5/gst-plugins-good-1.14.5/sys/v4l2/gstv4l2object.c
index 124c778..8fdcc42 100644
--- a/gst_1.14.5/gst-plugins-good-1.14.5/sys/v4l2/gstv4l2object.c
+++ b/gst_1.14.5/gst-plugins-good-1.14.5/sys/v4l2/gstv4l2object.c
@@ -157,10 +157,10 @@ static const GstV4L2FormatDesc gst_v4l2_formats[] = {
   {V4L2_PIX_FMT_NV42, TRUE, GST_V4L2_RAW},
 
   /* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
-  {V4L2_PIX_FMT_SBGGR8, TRUE, GST_V4L2_CODEC},
-  {V4L2_PIX_FMT_SGBRG8, TRUE, GST_V4L2_CODEC},
-  {V4L2_PIX_FMT_SGRBG8, TRUE, GST_V4L2_CODEC},
-  {V4L2_PIX_FMT_SRGGB8, TRUE, GST_V4L2_CODEC},
+  {V4L2_PIX_FMT_SBGGR10, TRUE, GST_V4L2_CODEC},
+  {V4L2_PIX_FMT_SGBRG10, TRUE, GST_V4L2_CODEC},
+  {V4L2_PIX_FMT_SGRBG10, TRUE, GST_V4L2_CODEC},
+  {V4L2_PIX_FMT_SRGGB10, TRUE, GST_V4L2_CODEC},
 
   /* compressed formats */
   {V4L2_PIX_FMT_MJPEG, FALSE, GST_V4L2_CODEC},
@@ -1098,10 +1098,10 @@ gst_v4l2_object_format_get_rank (const struct v4l2_fmtdesc *fmt)
       rank = 0;
       break;
 
-    case V4L2_PIX_FMT_SBGGR8:
-    case V4L2_PIX_FMT_SGBRG8:
-    case V4L2_PIX_FMT_SGRBG8:
-    case V4L2_PIX_FMT_SRGGB8:
+    case V4L2_PIX_FMT_SBGGR10:
+    case V4L2_PIX_FMT_SGBRG10:
+    case V4L2_PIX_FMT_SGRBG10:
+    case V4L2_PIX_FMT_SRGGB10:
       rank = BAYER_BASE_RANK;
       break;
 
@@ -1498,15 +1498,15 @@ gst_v4l2_object_v4l2fourcc_to_bare_struct (guint32 fourcc)
       break;
     case V4L2_PIX_FMT_WNVA:    /* Winnov hw compres */
       break;
-    case V4L2_PIX_FMT_SBGGR8:
-    case V4L2_PIX_FMT_SGBRG8:
-    case V4L2_PIX_FMT_SGRBG8:
-    case V4L2_PIX_FMT_SRGGB8:
+    case V4L2_PIX_FMT_SBGGR10:
+    case V4L2_PIX_FMT_SGBRG10:
+    case V4L2_PIX_FMT_SGRBG10:
+    case V4L2_PIX_FMT_SRGGB10:
       structure = gst_structure_new ("video/x-bayer", "format", G_TYPE_STRING,
-          fourcc == V4L2_PIX_FMT_SBGGR8 ? "bggr" :
-          fourcc == V4L2_PIX_FMT_SGBRG8 ? "gbrg" :
-          fourcc == V4L2_PIX_FMT_SGRBG8 ? "grbg" :
-          /* fourcc == V4L2_PIX_FMT_SRGGB8 ? */ "rggb", NULL);
+          fourcc == V4L2_PIX_FMT_SBGGR10 ? "bggr" :
+          fourcc == V4L2_PIX_FMT_SGBRG10 ? "gbrg" :
+          fourcc == V4L2_PIX_FMT_SGRBG10 ? "grbg" :
+          fourcc == V4L2_PIX_FMT_SRGGB10 ? "rggb" : "rggb", NULL);
       break;
     case V4L2_PIX_FMT_SN9C10X:
       structure = gst_structure_new_empty ("video/x-sonix");
@@ -1817,13 +1817,13 @@ gst_v4l2_object_get_caps_info (GstV4l2Object * v4l2object, GstCaps * caps,
       const gchar *format = gst_structure_get_string (structure, "format");
       if (format) {
         if (!g_ascii_strcasecmp (format, "bggr"))
-          fourcc = V4L2_PIX_FMT_SBGGR8;
+          fourcc = V4L2_PIX_FMT_SBGGR10;
         else if (!g_ascii_strcasecmp (format, "gbrg"))
-          fourcc = V4L2_PIX_FMT_SGBRG8;
+          fourcc = V4L2_PIX_FMT_SGBRG10;
         else if (!g_ascii_strcasecmp (format, "grbg"))
-          fourcc = V4L2_PIX_FMT_SGRBG8;
+          fourcc = V4L2_PIX_FMT_SGRBG10;
         else if (!g_ascii_strcasecmp (format, "rggb"))
-          fourcc = V4L2_PIX_FMT_SRGGB8;
+          fourcc = V4L2_PIX_FMT_SRGGB10;
       }
     } else if (g_str_equal (mimetype, "video/x-sonix")) {
       fourcc = V4L2_PIX_FMT_SN9C10X;

Apply the patch

cd ..
quilt push

2- Recompile the plugins good:

cd gst-plugins-good-$VERSION
./configure --prefix=/home/$USER/gst_$VERSION/out ; time make ; make install ;

3- Export the libraries:

VERSION=1.14.5
export LD_LIBRARY_PATH=/home/$USER/gst_$VERSION/out/lib/

4- Capturing from a sensor using RAW10 in either rggb,gbrg,grbg ot bggr pixel order using gstreamer should be posible now, try running the following example pipeline:

gst-launch-1.0 -vvv v4l2src num-buffers=10  ! "video/x-bayer,width=1920,height=1080 format=bggr" ! fakesink -v

gst-launch-1.0 -vvv v4l2src num-buffers=10  ! "video/x-bayer,width=1920,height=1080,format=bggr,framerate=30/1" ! multifilesink location=test%d.raw  -v

See also

Tegra X1
Gstreamer pipelines for Tegra X1
Compiling Tegra X1 source code

Contact Us



For direct inquiries, please refer to the contact information available on our Contact page. Alternatively, you may complete and submit the form provided at the same link. We will respond to your request at our earliest opportunity.


Links to RidgeRun Resources and RidgeRun Artificial Intelligence Solutions can be found in the footer below.