Compile GStreamer on NVIDIA Jetson TX1, TX2, and Nano
|
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
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.