nvjpegdec slower then jpegdec in gstreamer

I’m testing the Logitech Brio (4K Pro) camera and have problems with the hardware decode of the jpeg. I was expecting nvjpegdec to support 4k at 30 frames but it’s not, the frame rate is pretty low. The software decode has no problems. I’m on the JetPack 4.2.

This is the gstreamer pipeline:
gst-launch-1.0 v4l2src device=/dev/video0 ! “image/jpeg,width=3840,height=2160, framerate=30/1” ! nvjpegdec ! xvimagesink -e

Any ideas why the nvjpegdec would be slower then jpegdec?

Thanks,
~Johnny

Hi,
Can you please try nvoverlaysink?

gst-launch-1.0 v4l2src device=/dev/video0 ! "image/jpeg,width=3840,height=2160, framerate=30/1" ! nvjpegdec ! video/x-raw ! nvvidconv ! 'video/x-raw(memory:NVMM),format=NV12' ! nvoverlaysink -e

Also we have tegra_multimedia_api sample 12_camera_v4l2_cuda demonstrating decoding mjpeg v4l2 source through NvJpegDecoder.

No luck with that pipeline, red screen in 3840x2160 and very slow in 1920x1080. Thank you for pointing me to the 12_camera_v4l2_cuda sample, it’s working perfectly there.

Hello, any idea how to decode MJPEG stream from v4l2 (Logitech c920 usb camera) with nvidia gstreamer plugins? Recommendation above also does not work for me. 12_camera_v4l2_cuda works good, but requires writing a separate code in order to capture stream in efficient way.

Hi,
12_camera_v4l2_cuda is with better performance. If you have to use gstreamer pipeline, you may revise #2 to supported resolution of Logitech c920.

how to build the example? it throws to me :

/usr/src/tegra_multimedia_api/samples/12_camera_v4l2_cuda$ make
make: Nothing to be done for 'all'.

:/usr/src/tegra_multimedia_api/samples/12_camera_v4l2_cuda$ ls
Makefile  camera_v4l2_cuda      camera_v4l2_cuda.h
build     camera_v4l2_cuda.cpp  camera_v4l2_cuda.o

Hi,
It is compiled while installing the samples through SDK Manager.

Hi DaneLLL,
Thank you for your response.
It is good to know, though it is not the case in my case, as it seems to me[probably because some 10.1-10.0 cuda version mismatch has taken place while installing with SDK], but I will try again at another device via reflash with SDK manager if there are no other ways out with it.
Thanks

May be you could point out how to deselect components in the SDK manager in a way it won’t install OpenCV, but will install Multimedia samples? And how deselect host components? If I will go with the defaults it will stuck at the point of cuda mismatch at the host that I can not deselect, and if it goes further, as I can not deselect openCV, it will affect the custom OpenCV installation, highly likely


What I am getting after such installation is:

locate camera_v4l2
/usr/src/tegra_multimedia_api/samples/12_camera_v4l2_cuda
/usr/src/tegra_multimedia_api/samples/12_camera_v4l2_cuda/Makefile
/usr/src/tegra_multimedia_api/samples/12_camera_v4l2_cuda/camera_v4l2_cuda
/usr/src/tegra_multimedia_api/samples/12_camera_v4l2_cuda/camera_v4l2_cuda.cpp
/usr/src/tegra_multimedia_api/samples/12_camera_v4l2_cuda/camera_v4l2_cuda.h
/usr/src/tegra_multimedia_api/samples/12_camera_v4l2_cuda/camera_v4l2_cuda.o

could you provide how will look an example for zed stereolabs with it, please?

./camera_v4l2_cuda -d /dev/video1 -s 640x480 -f YUYV -n 30 -c

gives a noise rather than a image

Hi Andrey1984,
Your issue looks different from this topic? It is better to start a new post for clearness.

Nah, the issue has been resolved, at least the first one that I have met.
It just tended to take a form of a convolution bug when resolving one issue derives in another issue.
Thank you for the suggestion. I shall start a new thread for investigating how to read from zed stereolabs with the sample “camera_v4l2_cuda”.

@DaneLLL

For some reason #2 is incredibly slow.

gst-launch-1.0 v4l2src device=/dev/video0 ! "image/jpeg,width=1920,height=1080, framerate=30/1" ! nvjpegdec ! video/x-raw ! nvvidconv ! 'video/x-raw(memory:NVMM),format=NV12' ! nvoverlaysink -e

Software decoder jpegdec is much faster in that case, but has quite CPU load.

gst-launch-1.0 v4l2src device="/dev/video0" ! "image/jpeg, width=1920, height=1080, framerate=30/1, format=(string)MJPG" ! jpegdec ! autovideosink

Hardware decoding works fine with h264 so far. That’s why i was really curious to get jpeg decoding work, because h264 is quite overhead for me.

gst-launch-1.0 v4l2src device="/dev/video0" ! "video/x-h264, width=1280, height=720, framerate=30/1" ! nvv4l2decoder ! autovideosink

Hi,
Please add io-mode=2 to v4l2src and try.

$ gst-launch-1.0 v4l2src device=/dev/video1 <b>io-mode=2</b> ! 'image/jpeg,width=1920,height=1080, framerate=30/1' ! nvjpegdec ! video/x-raw ! nvvidconv ! 'video/x-raw(memory:NVMM)' ! nvoverlaysink

Still the same, getting 70-100% CPU load and really slow :(

After a fresh reboot, you may first boost your jetson with:

sudo nvpmodel -m0 # set to MAXN mode
sudo jetson_clocks  # or sudo ~/jetson_clocks.sh in older releases

Then try using another display sink such as xvimagesink. This seems working (at least for a little while):

gst-launch-1.0 -ev videotestsrc ! nvjpegenc ! "image/jpeg, width=1920, height=1080, framerate=24/1, format=(string)MJPG" ! nvjpegdec ! fpsdisplaysink video-sink=xvimagesink

while without specifying xvimagesink output it uses autovideosink but this doesn’t work.

I’m remotely using a Xavier headless setup and I’m seeing bad things in some cases where I need to switch to another virtual console from TX2 host for getting focus control back, however the ssh -Y terminal where I’ve launched the pipeline into Xavier from TX2 never stops although received many Ctrl-C…dmesg nor syslog showing any error, but it shows:

nvbuf_utils: dmabuf_fd -1 mapped entry NOT found
nvbuf_utils: dmabuf_fd -1 mapped entry NOT found

Hi,
We have run r32.1/Xavier + Logitech C930e

$ sudo jetson_clocks
$ gst-launch-1.0 v4l2src device=/dev/video0 io-mode=2 ! 'image/jpeg,width=1920,height=1080, framerate=30/1' ! nvjpegdec ! video/x-raw ! nvvidconv ! 'video/x-raw(memory:NVMM)' ! fpsdisplaysink video-sink=nvoverlaysink text-overlay=false -v

Framerate is 30fps

/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 541, dropped: 2, current: 30.07, average: 29.86
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 556, dropped: 2, current: 30.00, average: 29.86
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 572, dropped: 2, current: 29.84, average: 29.86

tegrastats

RAM 2490/15692MB (lfb 3148x4MB) CPU [4%@1190,1%@1190,22%@1190,9%@1190,off,off,off,off] EMC_FREQ 2%@1331 GR3D_FREQ 0%@675 APE 150 MTS fg 0% bg 3% AO@34.5C GPU@35C Tboard@37C Tdiode@38.75C AUX@34C CPU@36C thermal@34.9C PMIC@100C GPU 311/311 CPU 311/311 SOC 2490/2490 CV 0/0 VDDRQ 311/311 SYS5V 2608/2608
RAM 2496/15692MB (lfb 3146x4MB) CPU [3%@1190,0%@1190,13%@1190,14%@1190,off,off,off,off] EMC_FREQ 2%@1331 GR3D_FREQ 0%@675 APE 150 MTS fg 0% bg 2% AO@34C GPU@35C Tboard@37C Tdiode@38.25C AUX@34C CPU@36C thermal@34.75C PMIC@100C GPU 311/311 CPU 311/311 SOC 2490/2490 CV 0/0 VDDRQ 311/311 SYS5V 2608/2608
RAM 2503/15692MB (lfb 3145x4MB) CPU [5%@1190,2%@1190,16%@1190,13%@1190,off,off,off,off] EMC_FREQ 2%@1331 GR3D_FREQ 0%@675 APE 150 MTS fg 0% bg 3% AO@34C GPU@35C Tboard@37C Tdiode@38.25C AUX@34C CPU@35.5C thermal@34.9C PMIC@100C GPU 311/311 CPU 311/311 SOC 2490/2490 CV 0/0 VDDRQ 311/311 SYS5V 2608/2608

FYI.

@DaneLLL,

Thanks for sharing. With R31.1 and headless setup, I can indeed get 75fps encoding with nvjpengenc and decoding with nvjpegdec with this path:

gst-launch-1.0 -ev videotestsrc ! 'video/x-raw,format=NV12, width=1920, height=1080,framerate=75/1' ! nvvidconv ! 'video/x-raw(memory:NVMM),format=I420' ! nvjpegenc ! 'image/jpeg, width=1920, height=1080, format=(string)MJPG' ! nvjpegdec ! 'video/x-raw(memory:NVMM),format=I420' ! fpsdisplaysink video-sink=fakesink text-overlay=false

Hello, finally was able to retest. Following is working fine. Seems “io-mode=2” makes a difference (not sure why did not work for me week ago :/)

gst-launch-1.0 v4l2src device=/dev/video0 io-mode=2 ! 'image/jpeg,width=1920,height=1080, framerate=30/1' ! nvjpegdec ! video/x-raw ! nvvidconv ! 'video/x-raw(memory:NVMM)' ! fpsdisplaysink video-sink=fakesink text-overlay=false -v

Thanks everyone for help.

nvjpegdec is able to directly output into NVMM memory, so you may try to remove nvvidconv.