Live Streaming over USB on Ubuntu and Linux, NVIDIA Jetson

You may also want to check this out, I haven’t done much other than compiled it all and run it

It gives me a doubling of the frame rate on the jetson. Use this as the guide for ffmpeg compilation on the jetson

https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

but use the ffmpeg git repo mentioned in the jetson-ffmpeg github as part of the ffmpeg compilation.

2 Likes

Wow. amazing. Is the version that is installed with “apt” not using hardware acceleration fully?

I guess this module works for both hardware encoding and hardware decoding?

h264_nvmpi

I’m going to add this to the community document. thanks!

The Nvidia forums seem to indicate they are still thinking about whether to optimise FFmpeg. So the standard ffmpeg doesn’t seem to be.

1 Like

Thanks. This is very useful to know as the 4K streams are a bit heavy to deal with. There’s some nice satisfaction in pushing that little Nano. The Xavier NX would also be nice, but a bit out of my budget at the moment.

hi, What command line would you use to save the stream of the Jetson Nano in a file video with the help of this project ?

Hello sir, I copy pasted exactly your command line and got :
" h264parse: command not found"
Any idea?

Actually even the first line alone gives me the following :
GStreamer-CRITICAL **: 00:03:56.424: gst_element_make_from_uri: assertion ‘gst_uri_is_valid (uri)’ failed
WARNING : erroneous pipeline: no element “video”

NB: I am running it on my Jetson Nano, with gst_loopback running

This was contributed by snaffu666.

You must adjust the /dev/video99 to the device of your THETA.

gst-launch-1.0 v4l2src device=/dev/video99 ! video/x-raw,framerate=30/1
! nvvidconv
! omxh264enc
! h264parse ! matroskamux \
! filesink location=vid99.mkv

Did you install all the plug-ins, include gst-plugins-bad?

Use the command below to identify missing gstreamer plug-ins and where to install it from.

$ gst-inspect-1.0 h264parse
Factory Details:
  Rank                     primary + 1 (257)
  Long-name                H.264 parser
  Klass                    Codec/Parser/Converter/Video
  Description              Parses H.264 streams
  Author                   Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>

Plugin Details:
  Name                     videoparsersbad
  Description              videoparsers
  Filename                 /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstvideoparsersbad.so
  Version                  1.14.5
  License                  LGPL
  Source module            gst-plugins-bad
  Source release date      2019-05-29
  Binary package           GStreamer Bad Plugins (Ubuntu)
  Origin URL               https://launchpad.net/distros/ubuntu/+source/gst-plugins-bad1.0

Paste your entire pipeline from gst-launch-1.0 into the forum.

Paste your code snippet of gst_viewer.c from roughly line 186 to line 193. Make sure the snippet includes the code after pipe_proc = in the if statement for gst_loopback.

the plugin probably is not installed in your system. the command “gst-inspect-1.0” will tell you what gstreamer elements are installed on your system.

i believe that h264parse is part of gstreamer1.0-plugins-bad

2 Likes

That’s a great point. If @Mehdi_Zayene doesn’t have the h264parse plug-in installed, then gst-inspect-1.0 h264parse will show nothing.

One way to find out what Ubuntu package the plug-in is located in is to first search on Google or the gstreamer site.

Once you know it is in the plugins bad package, you can try apt-cache search to identify the name of the package

https://gstreamer.freedesktop.org/documentation/videoparsersbad/h264parse.html?gi-language=c

Alternately, you can install all the plug-ins, the good, the bad, and the ugly.

1 Like

Okay thank you all, I will give it a try tonight and will let you all know !

1 Like

You may not need everything, but this will install all gstreamer plug-ins.

$ sudo apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio libgstreamer-plugins-base1.0-dev

You must adjust the C code for gst_viewer.c to match the /dev/video* device of your particular setup. Likely, you need to set it to /dev/video0. Alternately, you can use the tip by snaffu666 and use the video_nr option of v4l2loopback.

1 Like

Hello again sir,
so I installed the gstramer plug-ins, instanciated the video device as vid99 as suggested and adjusted the C code of gst_viewer.c and still get the same error,
here you can find my pipeline and my error and also the result I get when I inspect h264parse.
Thank you for your help !!!

The gst-launch-1.0 needs to be on a single line.

gst-launch-1.0 v4l2src device=/dev/video99 ! video/x-raw,framerate=30/1 \
! videoconvert \
! videoscale \
! avenc_huffyuv \
! avimux \
! filesink location=raw.hfyu

If you break it up on separate lines, you need to use a \ character.

This document will get you started on using gst-launch-1.0

https://gstreamer.freedesktop.org/documentation/tools/gst-launch.html?gi-language=c

1 Like

hello, thank you again for all your help!
it really means a lot, so I run the command, it worked and the resulted file is not corrupted! (hallelujah), but it has a problem of speed or fps… the video is not fluid at all, it seems to be accelerated a lot, I have a resulted video of 3seconds when I record for 23 seconds for example

Did you specify the framerate?
If you inspect the video information, does it show the correct information?

I used a stopwatch to take a 31 second clip. The video plays normally. The metadata indicates the correct time.

Post the actual pipeline you are using and encountering a problem.

1 Like

One other interesting aspect. The reason why I used huffman encoding is that I typically see a 30% lossless size reduction. This can be critical when saving to the SD card as there are bandwidth limitations on that front. You can always display directly with something like:

gst-launch-1.0 v4l2src device=/dev/video99 ! video/x-raw,framerate=30/1 \
! videoconvert \
! videoscale \
! xvimagesink

2 Likes

@craig @snafu666
here is what I get after inspection, video of 5sec instead of what’s shown in the terminal

the resulted video seems to be accelerated…