Simple Gstream USB Camera Live View

I have an ORIN AGX 64GB development module. I’ve literally just flashed it to factory defaults using the sdkmanager. I have a USB camera plugged into it. As a simple test I’m trying to view the USB camera’s live video. I’m attempting what I believe is the most ordinary, simplest command to use gstreamer to view the USB camera.

The following command fails though (output of the command included below the command):

svs@ubuntu:~$ gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/x-raw,framerate=30/1,width=1280,height=720 ! nvvidconv ! xvimagesink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.000165025
Setting pipeline to NULL ...
Freeing pipeline ...

The following even simpler command fails in a similar fashion:

nvgstcapture-1.0 --camsrc=0 --cap-dev-node=0
Encoder null, cannot set bitrate!
Encoder Profile = High
Runtime USB Camera Commands:

  Help : 'h'
  Quit : 'q'
  Set Capture Mode:
      mo:<val>
          (1): image
          (2): video
  Get Capture Mode:
      gmo
  Capture: enter 'j' OR
           followed by a timer (e.g., jx5000, capture after 5 seconds) OR
           followed by multishot count (e.g., j:6, capture 6 images)
           timer/multihot values are optional, capture defaults to single shot with timer=0s
  Start Recording : enter '1'
  Stop Recording  : enter '0'
  Set Preview Resolution:
      pcr:<val> e.g., pcr:2
          (0) : 176x144
          (1) : 320x240
          (2) : 640x480
          (3) : 1280x720
          (4) : 1920x1080
  NOTE: Preview/Encode resolution will be same as Capture resolution for USB-Camera
  Get Preview Resolution:
      gpcr
  Get Image Capture Resolution:
      gicr
  Get Video Capture Resolution:
      gvcr
  Set Capture Device Node:
      cdn:<val> e.g., cdn:0
          (0): /dev/video0
          (1): /dev/video1
          (2): /dev/video2
  Get Capture Device Node:
      gcdn


Runtime encoder configuration options:

  Set Encoding Bit-rate(in bytes):
      br:<val> e.g., br:4000000
  Get Encoding Bit-rate(in bytes):
      gbr
  Set Encoding Profile(only for H.264):
      ep:<val> e.g., ep:1
          (0): Baseline
          (1): Main
          (2): High
  Get Encoding Profile(only for H.264):
      gep
  Force IDR Frame on video Encoder(only for H.264):
      Enter 'f' 


** Message: 17:52:07.112: <main:4734> iterating capture loop ....
ERROR on bus: by /GstPipeline:capture_native_pipeline/GstBin:cap_bin/GstV4l2Src:v4l2src0: Internal data stream error.
debug info:
gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:capture_native_pipeline/GstBin:cap_bin/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
** Message: 17:52:07.162: <main:4744> Capture completed
** Message: 17:52:07.163: <main:4795> Camera application will now exit

Both commands seem to fail with "reason: not-negotiated(-4).

FYI, here is the output from the v4l2-ctl --list-formats-ext -d /dev/video0 command:

svs@ubuntu:~$ v4l2-ctl --list-formats-ext -d /dev/video0
ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'MJPG' (Motion-JPEG, compressed)
		Size: Discrete 2320x1744
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.040s (25.000 fps)
			Interval: Discrete 0.050s (20.000 fps)
			Interval: Discrete 0.067s (15.000 fps)
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.040s (25.000 fps)
			Interval: Discrete 0.050s (20.000 fps)
			Interval: Discrete 0.067s (15.000 fps)
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 4656x3496
			Interval: Discrete 0.100s (10.000 fps)
		Size: Discrete 4208x3120
			Interval: Discrete 0.100s (10.000 fps)
		Size: Discrete 4160x3120
			Interval: Discrete 0.100s (10.000 fps)
		Size: Discrete 4000x3000
			Interval: Discrete 0.100s (10.000 fps)
		Size: Discrete 3264x2448
			Interval: Discrete 0.100s (10.000 fps)
		Size: Discrete 2592x1944
			Interval: Discrete 0.100s (10.000 fps)
		Size: Discrete 2048x1536
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.040s (25.000 fps)
			Interval: Discrete 0.050s (20.000 fps)
			Interval: Discrete 0.067s (15.000 fps)
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 1920x1080
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.040s (25.000 fps)
			Interval: Discrete 0.050s (20.000 fps)
			Interval: Discrete 0.067s (15.000 fps)
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 1600x1200
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.040s (25.000 fps)
			Interval: Discrete 0.050s (20.000 fps)
			Interval: Discrete 0.067s (15.000 fps)
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 1280x960
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.040s (25.000 fps)
			Interval: Discrete 0.050s (20.000 fps)
			Interval: Discrete 0.067s (15.000 fps)
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 1280x720
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.040s (25.000 fps)
			Interval: Discrete 0.050s (20.000 fps)
			Interval: Discrete 0.067s (15.000 fps)
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 1024x768
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.040s (25.000 fps)
			Interval: Discrete 0.050s (20.000 fps)
			Interval: Discrete 0.067s (15.000 fps)
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 800x600
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.040s (25.000 fps)
			Interval: Discrete 0.050s (20.000 fps)
			Interval: Discrete 0.067s (15.000 fps)
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 640x480
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.040s (25.000 fps)
			Interval: Discrete 0.050s (20.000 fps)
			Interval: Discrete 0.067s (15.000 fps)
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 2320x1744
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.040s (25.000 fps)
			Interval: Discrete 0.050s (20.000 fps)
			Interval: Discrete 0.067s (15.000 fps)
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.040s (25.000 fps)
			Interval: Discrete 0.050s (20.000 fps)
			Interval: Discrete 0.067s (15.000 fps)
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
	[1]: 'YUYV' (YUYV 4:2:2)
		Size: Discrete 2320x1744
			Interval: Discrete 1.000s (1.000 fps)
			Interval: Discrete 1.000s (1.000 fps)
		Size: Discrete 4656x3496
			Interval: Discrete 1.000s (1.000 fps)
		Size: Discrete 3840x2160
			Interval: Discrete 1.000s (1.000 fps)
		Size: Discrete 3264x2448
			Interval: Discrete 1.000s (1.000 fps)
		Size: Discrete 2592x1944
			Interval: Discrete 1.000s (1.000 fps)
		Size: Discrete 2048x1536
			Interval: Discrete 1.000s (1.000 fps)
		Size: Discrete 1920x1080
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 1600x1200
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 1280x960
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 1280x720
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 1024x768
			Interval: Discrete 0.100s (10.000 fps)
			Interval: Discrete 0.200s (5.000 fps)
		Size: Discrete 800x600
			Interval: Discrete 0.067s (15.000 fps)
			Interval: Discrete 0.100s (10.000 fps)
		Size: Discrete 2320x1744
			Interval: Discrete 1.000s (1.000 fps)
			Interval: Discrete 1.000s (1.000 fps)

Shouldn’t those two commands to view the USB camera work??? What am I doing wrong? Can anybody offer some advice?

I think this is main issue…nvvidconv would expect at least one of its input or output to be in NVMM, while in your case both v4l2src and xvimagesink around are using system memory (video/x-raw).

So for v4l2src in YUYV 4:2:2, v4l2-ctl --list-formats-ext reports 720p supported at 5 or 10 fps, so you would try:

gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=1280,height=720,framerate=10/1 ! queue ! xvimagesink

Or using MJPG capture, 720p would support 30 fps (note that nvv4l2decoder would output NV12 format into NVMM memory, so nvvidconv here for converting into a suitable format and copying into system memory for xvimagesink) :

gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg,format=MJPG,width=1280,height=720,framerate=30/1 ! jpegparse ! nvv4l2decoder mjpeg=1 ! nvvidconv ! queue ! autovideosink

# Or
gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg,format=MJPG,width=1280,height=720,framerate=30/1 ! jpegparse ! nvjpegdec ! nvvidconv ! queue ! autovideosink

AFAIK, nvgstcapture is designed for Argus managed sensors, not for UVC cameras.

1 Like

Hi Honey_Patouceul, thanks for the quick response and the explanations.

The YUYV command works awesome at 10 frames per second. Thanks :-) … I was hoping to get 30, so I’m trying your MJPG suggestions.

However, the first MJPG suggestion displays the window with the camera feed inside, but the camera feed looks like a still image. I did see, like, maybe 3 image updates in the window but that is it. The stdout indicates the computer is too slow.

gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg,format=MJPG,width=1280,height=720,framerate=30/1 ! jpegparse ! nvv4l2decoder mjpeg=1 ! nvvidconv ! queue ! xvimagesink
Setting pipeline to PAUSED ...
Opening in BLOCKING MODE 
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = image/jpeg, format=(string)MJPG, width=(int)1280, height=(int)720, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = image/jpeg, format=(string)MJPG, width=(int)1280, height=(int)720, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstJpegParse:jpegparse0.GstPad:sink: caps = image/jpeg, format=(string)MJPG, width=(int)1280, height=(int)720, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = image/jpeg, format=(string)MJPG, width=(int)1280, height=(int)720, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstJpegParse:jpegparse0.GstPad:src: caps = image/jpeg, parsed=(boolean)true, format=(string)UYVY, width=(int)1280, height=(int)720, framerate=(fraction)30/1
NvMMLiteOpen : Block : BlockType = 277 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 277 
/GstPipeline:pipeline0/nvv4l2decoder:nvv4l2decoder0.GstPad:sink: caps = image/jpeg, parsed=(boolean)true, format=(string)UYVY, width=(int)1280, height=(int)720, framerate=(fraction)30/1
/GstPipeline:pipeline0/nvv4l2decoder:nvv4l2decoder0.GstPad:src: caps = video/x-raw(memory:NVMM), format=(string)I420, width=(int)1280, height=(int)720, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)mpeg2, colorimetry=(string)bt709, framerate=(fraction)30/1, nvbuf-memory-type=(string)nvbuf-mem-surface-array, gpu-id=(int)0
/GstPipeline:pipeline0/Gstnvvconv:nvvconv0.GstPad:src: caps = video/x-raw, width=(int)1280, height=(int)720, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, nvbuf-memory-type=(string)nvbuf-mem-surface-array, gpu-id=(int)0, format=(string)YUY2
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:sink: caps = video/x-raw, width=(int)1280, height=(int)720, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, nvbuf-memory-type=(string)nvbuf-mem-surface-array, gpu-id=(int)0, format=(string)YUY2
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:src: caps = video/x-raw, width=(int)1280, height=(int)720, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, nvbuf-memory-type=(string)nvbuf-mem-surface-array, gpu-id=(int)0, format=(string)YUY2
/GstPipeline:pipeline0/GstXvImageSink:xvimagesink0.GstPad:sink: caps = video/x-raw, width=(int)1280, height=(int)720, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, nvbuf-memory-type=(string)nvbuf-mem-surface-array, gpu-id=(int)0, format=(string)YUY2
/GstPipeline:pipeline0/Gstnvvconv:nvvconv0.GstPad:sink: caps = video/x-raw(memory:NVMM), format=(string)I420, width=(int)1280, height=(int)720, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)mpeg2, colorimetry=(string)bt709, framerate=(fraction)30/1, nvbuf-memory-type=(string)nvbuf-mem-surface-array, gpu-id=(int)0
WARNING: from element /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0: A lot of buffers are being dropped.
Additional debug info:
gstbasesink.c(3003): gst_base_sink_is_too_late (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
There may be a timestamping problem, or this computer is too slow.
WARNING: from element /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0: A lot of buffers are being dropped.
Additional debug info:
gstbasesink.c(3003): gst_base_sink_is_too_late (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
There may be a timestamping problem, or this computer is too slow.

The second MJPG suggestion still has the “not negotiated” result:

svs@ubuntu:~/jetson-inference$ gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg,format=MJPG,width=1280,height=720,framerate=30/1 ! jpegparse ! nvjpegdec ! nvvidconv ! queue ! xvimagesink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = image/jpeg, format=(string)MJPG, width=(int)1280, height=(int)720, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = image/jpeg, format=(string)MJPG, width=(int)1280, height=(int)720, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstJpegParse:jpegparse0.GstPad:sink: caps = image/jpeg, format=(string)MJPG, width=(int)1280, height=(int)720, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = image/jpeg, format=(string)MJPG, width=(int)1280, height=(int)720, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstJpegParse:jpegparse0.GstPad:src: caps = image/jpeg, parsed=(boolean)true, format=(string)UYVY, width=(int)1280, height=(int)720, framerate=(fraction)30/1
/GstPipeline:pipeline0/GstNvJpegDec:nvjpegdec0.GstPad:sink: caps = image/jpeg, parsed=(boolean)true, format=(string)UYVY, width=(int)1280, height=(int)720, framerate=(fraction)30/1
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.699569015
Setting pipeline to NULL ...
Freeing pipeline ...

As for the nvgstcapture utility, another developer asked a similar question to mine and NVIDIA referred them to an FAQ page that in turn sends us to the following NVIDIA document instructing us to use nvgstcapture even for basic USB camera testing:

https://developer.nvidia.com/embedded/learn/tutorials/first-picture-csi-usb-camera#CameraGuide-USBCamera

So, thanks again… looks like we are 60% there! Any follow-up suggestions on what to try next for the MJPG mechanism @ 30 fps?

Edited my post with autovideosink instead of xvimagesink, does it work better ?

Or try:

gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=720,framerate=30/1 ! jpegparse ! nvv4l2decoder mjpeg=1 ! nvvidconv ! identity ! queue ! xvimagesink

Same exact results for both of the 2 suggestions up above even using autovideosink in place of xvimagesink.

Then for the new suggestion the result is a very slow update rate of about 1 frame every 2 to 3 seconds.

gst-launch-1.0 v4l2src device=/dev/video0 ! jpegparse ! nvv4l2decoder mjpeg=1 ! nvvidconv ! identity ! xvimagesink
Setting pipeline to PAUSED ...
Opening in BLOCKING MODE 
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
NvMMLiteOpen : Block : BlockType = 277 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 277 
WARNING: from element /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0: A lot of buffers are being dropped.
Additional debug info:
gstbasesink.c(3003): gst_base_sink_is_too_late (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
There may be a timestamping problem, or this computer is too slow.
WARNING: from element /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0: A lot of buffers are being dropped.
Additional debug info:
gstbasesink.c(3003): gst_base_sink_is_too_late (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
There may be a timestamping problem, or this computer is too slow.
WARNING: from element /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0: A lot of buffers are being dropped.
Additional debug info:
gstbasesink.c(3003): gst_base_sink_is_too_late (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
There may be a timestamping problem, or this computer is too slow.
WARNING: from element /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0: A lot of buffers are being dropped.
Additional debug info:
gstbasesink.c(3003): gst_base_sink_is_too_late (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
There may be a timestamping problem, or this computer is too slow.

The “too slow” info message repeats in the stdout each time a new frame is rendered in the video window about once every 2 to 3 seconds.

Thoughts???

Thanks!

You may try my last edit adding a queue… Or try removing jpegparse.

1 Like

Adding the queue to your third MJPG suggestion results in seeing just a single frame that never updates. The stdout displays the “too slow” message.

Taking your first suggestion and removing “jpegparse” solves the problem. Here’s the golden :-) command:

gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg, width=1280, height=720, framerate=30/1, format=MJPG ! jpegdec ! xvimagesink

It also works just as great using “autovideosink” in place of “xvimagesink”:

gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg, width=1280, height=720, framerate=30/1, format=MJPG ! jpegdec ! autovideosink

Thanks so much!!!

Glad to see you’ve moved forward.
Though, be aware that jpegdec is CPU-based, while you may use Jetson HW for decoding:

  • Using nvv4l2decoder with property mjpeg set to true, this would output NV12 format into NVMM memory.
  • Using nvjpegdec. This may output NV12 or I420 format into NVMM or system memory.

You may experiment with your MJPG camera and optimize. Have fun and share!

1 Like

Hmmm… I will need hardware encoding. Good catch!

So…replacing jpegdec with nvjpegdec results in that dreaded “not negotiated” error.

gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg, width=1280, height=720, framerate=30/1, format=MJPG ! nvjpegdec ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, format=(string)MJPG, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, format=(string)MJPG, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstNvJpegDec:nvjpegdec0.GstPad:sink: caps = image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, format=(string)MJPG, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, format=(string)MJPG, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.695535596
Setting pipeline to NULL ...
Freeing pipeline ...

I’ll play with it some more tomorrow. Thanks for your help so far. At least we’ve found a CPU solution. Hopefully we’ll be able to find a full hw solution.

Try adding nvvidconv between nvjpegdec and videosink. Also try adding a queue or even identity there.

No luck. None of these work:

  • gst-launch-1.0 -vvv v4l2src device=/dev/video0 ! image/jpeg, width=1280, height=720, framerate=30/1, format=MJPG ! nvjpegdec ! nvvidconv ! identity ! autovideosink

  • gst-launch-1.0 -vvv v4l2src device=/dev/video0 ! image/jpeg, width=1280, height=720, framerate=30/1, format=MJPG ! nvjpegdec ! nvvidconv ! queue ! identity ! autovideosink

  • gst-launch-1.0 -vvv v4l2src device=/dev/video0 ! image/jpeg, width=1280, height=720, framerate=30/1, format=MJPG ! nvjpegdec ! nvvidconv ! queue ! autovideosink

  • gst-launch-1.0 -vvv v4l2src device=/dev/video0 ! image/jpeg, width=1280, height=720, framerate=30/1, format=MJPG ! nvjpegdec ! queue ! nvvidconv ! autovideosink

  • gst-launch-1.0 -vvv v4l2src device=/dev/video0 ! image/jpeg, width=1280, height=720, framerate=30/1, format=MJPG ! nvjpegdec ! nvvidconv ! autovideosink

All result in the dreaded “not negotiated” error. I’ll keep trying tomorrow.

You may remove the format=MJPG cap, as your camera only has MJPG format for JPEG capture.
I’d also suggest to have at least one queue in each pipeline at first trial.

Also try using the nvv4l2decoder mjpeg=1 way.

Sorry I don’t even have a real JPEG camera, I’m just emulating your case with v4l2loopback. Have fun!

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