DS/Gstreamer jpegdec vs nvjpegdec

Hi,

I’m running into performance issue (fps) with a video pipeline using gstreamer plugins.
I think i have several problems.
Let’s work on them 1 by 1 if it is OK.

For the context in my application I have a camera connected to USB and detection run locally and detection from “outside”.

When i use a MJPEG 1280x720 capable camera i have created an equivalent pipeline to facilitate profiling and debug

case 1

gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=720 ! jpegdec ! nvvidconv ! 'video/x-raw(memory:NVMM),format=RGBA' ! nvdsosd display-bbox=false display-clock=false ! nv3dsink sync=false

In case 1 the pipeline run and the latency is low (CPU decode is around 5ms) and FPS is 60 fps
see case1.zip for nsight trace

case1.zip (932.3 KB)

To improve performance i want to use the HW JPEG decoder to free some ressources

** case 2**

gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=720 ! nvjpegdec ! 'video/x-raw(memory:NVMM),format=RGBA' ! nvdsosd display-bbox=false display-clock=false ! nv3dsink sync=false

replacing the jpegdec with nvjpegdec and also removing nvvidconv because the src pad of nvjpegdec is compatible with NVMM memory

gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=720 ! nvjpegdec ! 'video/x-raw(memory:NVMM),format=RGBA' ! nvdsosd display-bbox=false display-clock=false ! nv3dsink sync=false
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
NvMMLiteOpen : Block : BlockType = 277 
NvMMLiteBlockCreate : Block : BlockType = 277 
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.805718343
Setting pipeline to NULL ...
ERROR: from element /GstPipeline:pipeline0/GstNvJpegDec:nvjpegdec0: No valid frames decoded before end of stream
Additional debug info:
../gst-libs/gst/video/gstvideodecoder.c(1416): gst_video_decoder_sink_event_default (): /GstPipeline:pipeline0/GstNvJpegDec:nvjpegdec0:
no valid frames found
Freeing pipeline ...
NVMMLITE_NVVIDEODEC, <NvVideoBufferProcessing:6121> Consume the extra signalling for EOS

with GST_DEBUG=3

GST_DEBUG=3 gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=720 ! nvjpegdec ! 'video/x-raw(memory:NVMM),format=RGBA' ! nvdsosd display-bbox=false display-clock=false ! nv3dsink sync=false
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
0:00:00.289047831 357441 0xaaaacc508a40 FIXME           videodecoder gstvideodecoder.c:1193:gst_video_decoder_drain_out:<nvjpegdec0> Sub-class should implement drain()
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:00.681804743 357441 0xaaaacc508a40 WARN          v4l2bufferpool gstv4l2bufferpool.c:842:gst_v4l2_buffer_pool_start:<v4l2src0:pool0:src> Uncertain or not enough buffers, enabling copy threshold
NvMMLiteOpen : Block : BlockType = 277 
NvMMLiteBlockCreate : Block : BlockType = 277 
0:00:01.161616812 357441 0xaaaacc508a40 ERROR                jpegdec gstjpegdec.c:1163:gst_jpeg_dec_negotiate:<nvjpegdec0> Empty caps
0:00:01.161818962 357441 0xaaaacc508a40 WARN            videodecoder gstvideodecoder.c:4797:_gst_video_decoder_error:<nvjpegdec0> error: Failed to negotiate caps
0:00:01.161834675 357441 0xaaaacc508a40 WARN            videodecoder gstvideodecoder.c:4799:_gst_video_decoder_error:<nvjpegdec0> error: Picture is too small or too big (1280x720)
0:00:01.161919158 357441 0xaaaacc508a40 WARN                 basesrc gstbasesrc.c:3127:gst_base_src_loop:<v4l2src0> error: Internal data stream error.
0:00:01.161931766 357441 0xaaaacc508a40 WARN                 basesrc gstbasesrc.c:3127:gst_base_src_loop:<v4l2src0> error: streaming stopped, reason not-negotiated (-4)
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.872891552
0:00:01.162075387 357441 0xaaaacc508a40 WARN            videodecoder gstvideodecoder.c:1416:gst_video_decoder_sink_event_default:<nvjpegdec0> error: No valid frames decoded before end of stream
Setting pipeline to NULL ...
0:00:01.162087899 357441 0xaaaacc508a40 WARN            videodecoder gstvideodecoder.c:1416:gst_video_decoder_sink_event_default:<nvjpegdec0> error: no valid frames found
ERROR: from element /GstPipeline:pipeline0/GstNvJpegDec:nvjpegdec0: No valid frames decoded before end of stream
Additional debug info:
../gst-libs/gst/video/gstvideodecoder.c(1416): gst_video_decoder_sink_event_default (): /GstPipeline:pipeline0/GstNvJpegDec:nvjpegdec0:
no valid frames found
Freeing pipeline ...
NVMMLITE_NVVIDEODEC, <NvVideoBufferProcessing:6121> Consume the extra signalling for EOS

thks in advance

*** Please note that this reply is generated by LLM automatically ***

Based on the provided context, it seems like you’re experiencing performance issues with a video pipeline using GStreamer plugins on a Jetson Orin Nano device. You’ve identified two cases, and I’ll address each one separately.

Case 1:

In this case, you’re using a MJPEG 1280x720 capable camera, and the pipeline is running with low latency (CPU decode around 5ms) and 60 FPS. You’ve provided a nsight trace file (case1.zip) for profiling and debugging.

Case 2:

To improve performance, you want to use the HW JPEG decoder (nvjpegdec) to free up resources. You’ve replaced the jpegdec with nvjpegdec and removed nvvidconv, as the src pad of nvjpegdec is compatible with NVMM memory.

Comparison and Suggestions:

  1. JPEG Decoder: By replacing jpegdec with nvjpegdec, you’re leveraging the hardware-accelerated JPEG decoder on the Jetson Orin Nano. This should reduce the CPU load and improve overall performance.
  2. nvvidconv removal: Since the src pad of nvjpegdec is compatible with NVMM memory, removing nvvidconv is a good decision. This reduces the number of components in the pipeline and minimizes potential bottlenecks.
  3. GST_DEBUG: Using GST_DEBUG=3 will provide more detailed debug information, which can help you identify potential issues in the pipeline.

To further optimize the pipeline, consider the following:

  • Verify nvjpegdec configuration: Ensure that nvjpegdec is properly configured to take advantage of the HW JPEG decoder. You can use the gst-inspect-1.0 tool to inspect the nvjpegdec element and verify its properties.
  • Monitor system resources: Keep an eye on system resources (CPU, memory, and GPU) to ensure that the pipeline is not bottlenecked by any of these components.
  • Experiment with different settings: Try adjusting various settings, such as the JPEG quality, to find the optimal balance between quality and performance.
  • Consider using a more efficient video format: If possible, consider using a more efficient video format, such as H.264 or H.265, which can provide better compression and reduce the overall bitrate.

By following these suggestions and monitoring the pipeline’s performance, you should be able to identify and address any remaining performance issues.

*** Please give the thumbs up if you get answers you like. Or provide feedback to help us improve the answer. ***

Following guidelines i have tries to set rgbaoutput but no success

GST_DEBUG=3 gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=640,height=480 ! nvjpegdec rgbaoutput=true ! 'video/x-raw(memory:NVMM),format=RGBA' ! nvdsosd display-bbox=false display-clock=false ! nv3dsink sync=false
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
0:00:00.294941338 359530 0xaaaaed47e240 FIXME           videodecoder gstvideodecoder.c:1193:gst_video_decoder_drain_out:<nvjpegdec0> Sub-class should implement drain()
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:00.295329063 359530 0xaaaaed47e240 WARN                 basesrc gstbasesrc.c:3127:gst_base_src_loop:<v4l2src0> error: Internal data stream error.
0:00:00.295348263 359530 0xaaaaed47e240 WARN                 basesrc gstbasesrc.c:3127:gst_base_src_loop:<v4l2src0> error: streaming stopped, reason not-negotiated (-4)
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.000391021
Setting pipeline to NULL ...
Freeing pipeline ...

Jetson Orin Nano dev kit
CUDA: 12.6.68
cuDNN: 9.3.0.75
TensoRT: 10.3.0.30

Package: nvidia-jetpack
Source: nvidia-jetpack (6.2.1)
Version: 6.2.1+b38
Architecture: arm64
Maintainer: NVIDIA Corporation
Installed-Size: 194
Depends: nvidia-jetpack-runtime (= 6.2.1+b38), nvidia-jetpack-dev (= 6.2.1+b38)
Homepage: Jetson - Embedded AI Computing Platform | NVIDIA Developer
Priority: standard
Section: metapackages
Filename: pool/main/n/nvidia-jetpack/nvidia-jetpack_6.2.1+b38_arm64.deb
Size: 29300
SHA256: dd9cb893fbe7f80d2c2348b268f17c8140b18b9dbb674fa8d79facfaa2050c53
SHA1: dc630f213f9afcb6f67c65234df7ad5c019edb9c
MD5sum: 9c8dc61bdab2b816dcc7cd253bcf6482
Description: NVIDIA Jetpack Meta Package
Description-md5: ad1462289bdbc54909ae109d1d32c0a8

Hi,
Please try nvv4l2decoder to use hardware JPEG decoder:

... ! nvv4l2decoder mjpeg=1 ! ...

Hi,
Yes i did

with… ! jpegdec ! nvvidconv !` … OK

gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=720 ! jpegdec ! nvvidconv ! 'video/x-raw(memory:NVMM),format=RGBA' ! nvdsosd display-bbox=false display-clock=false ! nv3dsink sync=false
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:07.893780101
Setting pipeline to NULL ...
Freeing pipeline ...

with nvv4l2decoder mjpeg KO

gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=720 ! nvv4l2decoder mjpeg=1 ! 'video/x-raw(memory:NVMM),format=RGBA' ! nvdsosd display-bbox=false display-clock=false ! nv3dsink sync=false
Setting pipeline to PAUSED ...
Opening in BLOCKING MODE 
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
NvMMLiteOpen : Block : BlockType = 277 
NvMMLiteBlockCreate : Block : BlockType = 277 
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:02.485654620
Setting pipeline to NULL ...
Freeing pipeline ...

Hi,
Please try

... ! jpegparse ! nvv4l2decoder mjpeg=1 ! ...

If the same error is reported, it is very likely the format is not supported. The supported formats are YUV420, YUV422(UYVY, YUYV, …), YUV444.

You are asking to use nnv4l2decoder NOT ME !!I would like to use nvjpegdec that support:

 SRC template: 'src'
    Availability: Always
    Capabilities:
      video/x-raw(memory:NVMM)
                 format: { (string)I420, (string)GRAY8, (string)NV12, (string)YUY2, (string)Y42B, (string)Y444, (string)RGB, (string)RGBA }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]

including NVMM RGBA that is need in my pipeline.

thks

Hi,
It reports the error while using nvjpegdec:

ERROR: from element /GstPipeline:pipeline0/GstNvJpegDec:nvjpegdec0: No valid frames decoded before end of stream

Looks like the format is not supported in hardware JPEG decoder. Please confirm which format the JPEG source is.

gstreamer] initialized gstreamer, version 1.20.3.0
[gstreamer] gstCamera – attempting to create device v4l2:///dev/video0
[gstreamer] gstCamera – found v4l2 device: OBSBOT Meet SE: OBSBOT Meet SE
[gstreamer] v4l2-proplist, device.path=(string)/dev/video0, udev-probed=(boolean)false, device.api=(string)v4l2, v4l2.device.driver=(string)uvcvideo, v4l2.device.card=(string)"OBSBOT\ Meet\ SE:\ OBSBOT\ Meet\ SE\ ", v4l2.device.bus_info=(string)usb-3610000.usb-2.3, v4l2.device.version=(uint)331668, v4l2.device.capabilities=(uint)2225078273, v4l2.device.device_caps=(uint)69206017;
[gstreamer] gstCamera – found 4 caps for v4l2 device /dev/video0
[gstreamer] [0] video/x-raw, format=(string)YUY2, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 24/1, 20/1, 15/1 };
[gstreamer] [1] video/x-raw, format=(string)YUY2, width=(int)640, height=(int)360, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 24/1, 20/1, 15/1 };
[gstreamer] [2] image/jpeg, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 100/1, 60/1, 7013/117, 50/1, 30/1, 30060/1003, 25/1, 24/1, 20/1, 15/1 };
[gstreamer] [3] image/jpeg, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 150/1, 120/1, 60/1, 7013/117, 50/1, 30/1, 30060/1003, 25/1, 24/1, 20/1, 15/1 };
[gstreamer] gstCamera – selected device profile: codec=MJPEG format=unknown width=1280 height=720 framerate=30

Hi,
It looks like the camera can output YUY2, you may set to this format for a try.

And please run the command and share us the file:

$ gst-launch-1.0 v4l2src num-buffers=66 device=/dev/video0 ! image/jpeg,width=1280,height=720 ! filesink location=dump.mjpeg

We can try it on developer kit and see whether it can be decoded.

HI the output of ffprobe and the requested file

ffprobe -v error -show_format -show_streams dump.mjpeg 
[STREAM]
index=0
codec_name=mjpeg
codec_long_name=Motion JPEG
profile=Baseline
codec_type=video
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=1280
height=720
coded_width=1280
coded_height=720
closed_captions=0
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuvj422p
level=-99
color_range=pc
color_space=bt470bg
color_transfer=unknown
color_primaries=unknown
chroma_location=center
field_order=unknown
refs=1
id=N/A
r_frame_rate=25/1
avg_frame_rate=0/0
time_base=1/1200000
start_pts=N/A
start_time=N/A
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[FORMAT]
filename=dump.mjpeg
nb_streams=1
nb_programs=0
format_name=mjpeg
format_long_name=raw MJPEG video
start_time=N/A
duration=N/A
size=6362380
bit_rate=N/A
probe_score=25
[/FORMAT]

dump.zip (5.8 MB)

Hi,
We have tested and confirmed hardware JPEG decoder cannot decode the file. It is pix_fmt=yuvj422p and hardware JPEG decoder cannot decode the format. Please use software JPEG decoder.

This looks more like a bug … any workaround or partial HWdecode and cuda kernel ? any code ? to share.

Best regards

Michel C.

Hi,
This is hardware constraint. yuvj422p is not a supported format. Please use software decoder.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.