Inogeni 4K -> USB3.0 and gstreamer problem

I tried to capture video from Inogeni (/dev/video0) with gstreamer pipeline:

gst-launch-1.0 v4l2src device=/dev/video0 ! "video/x-raw,width=3840,height=2160,format=I420" ! fakesink

With GST_DEBUG="*:3" I see errors:

ubuntu@tegra-ubuntu:~$ gst-launch-1.0 v4l2src device=/dev/video0 ! "video/x-raw,width=3840,height=2160,format=I420" ! fakesink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:00.276135808 18119       0x60f320 WARN          v4l2bufferpool gstv4l2bufferpool.c:1196:gst_v4l2_buffer_pool_dqbuf:<v4l2src0:pool:src> Driver should never set v4l2_buffer.field to ANY
0:00:00.276210433 18119       0x60f320 WARN          v4l2bufferpool gstv4l2bufferpool.c:1958:gst_v4l2_buffer_pool_process:<v4l2src0:pool:src> Dropping corrupted buffer without payload
0:00:00.276253730 18119       0x60f320 WARN          v4l2bufferpool gstv4l2bufferpool.c:1958:gst_v4l2_buffer_pool_process:<v4l2src0:pool:src> Dropping corrupted buffer without payload
0:00:00.328871196 18119       0x60f320 ERROR                default video-frame.c:161:gst_video_frame_map_id: failed to map video frame plane 1
0:00:00.328947998 18119       0x60f320 ERROR         v4l2bufferpool gstv4l2bufferpool.c:161:gst_v4l2_buffer_pool_copy_buffer:<v4l2src0:pool:src> could not map buffer
0:00:00.328976798 18119       0x60f320 ERROR         v4l2bufferpool gstv4l2bufferpool.c:1953:gst_v4l2_buffer_pool_process:<v4l2src0:pool:src> failed to copy buffer
0:00:00.329004031 18119       0x60f320 WARN                 basesrc gstbasesrc.c:2939:gst_base_src_loop:<v4l2src0> error: Internal data stream error.
0:00:00.329015263 18119       0x60f320 WARN                 basesrc gstbasesrc.c:2939:gst_base_src_loop:<v4l2src0> error: streaming stopped, reason error (-5)
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(2939): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason error (-5)
Execution ended after 0:00:00.186888513
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

I tried NV12, YV12 formats, but nothing changed. It’s working only with RGB and high cpu usage. What I doing wrong?

Thanks

What do you want to do exactly? I’ve got one and it works great.

E.g.

gst-launch-1.0 v4l2src device=/dev/video1 ! glimagesink

(or xvimagesink)

Ah wait, just spotted the format comment - it’s I420 out of it, e.g. to grab pngs at 0.5fps

gst-launch-1.0 v4l2src device=/dev/video1 ! ‘video/x-raw, format=(string)I420,width=(int)3840, height=(int)2160,framerate=(fraction)30/1’ ! videorate ! “video/x-raw,framerate=1/2” ! videoconvert ! pngenc ! multifilesink location=img%03d.png

And you can use a nvvidconv if you need to convert it, e.g.:

! nvvidconv ! ‘video/x-raw(memory:NVMM), format=(string)NV12’ !

I don’t want convert frame via gstreamer.
I want to capture frame from Inogeni exactly in format that supported by Inogeni. For 4k Inogeni supports NV12, YV12 and I420 formats. On my laptop, pipeline from first post (with fakesink) works perfect, but on Jetson I see errors.

Your pipeline generate next errors:

gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw, format=(string)I420,width=(int)3840, height=(int)2160,framerate=(fraction)30/1' ! videorate ! "video/x-raw,framerate=1/2" ! videoconvert ! pngenc ! multifilesink location=img%03d.png
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:00.286948488  6538       0x612e80 WARN          v4l2bufferpool gstv4l2bufferpool.c:1196:gst_v4l2_buffer_pool_dqbuf:<v4l2src0:pool:src> Driver should never set v4l2_buffer.field to ANY
0:00:00.287018760  6538       0x612e80 WARN          v4l2bufferpool gstv4l2bufferpool.c:1958:gst_v4l2_buffer_pool_process:<v4l2src0:pool:src> Dropping corrupted buffer without payload
0:00:00.287069480  6538       0x612e80 WARN          v4l2bufferpool gstv4l2bufferpool.c:1958:gst_v4l2_buffer_pool_process:<v4l2src0:pool:src> Dropping corrupted buffer without payload
0:00:00.379680173  6538       0x612e80 ERROR                default video-frame.c:161:gst_video_frame_map_id: failed to map video frame plane 1
0:00:00.379756461  6538       0x612e80 WARN             videofilter gstvideofilter.c:292:gst_video_filter_transform:<videoconvert0> warning: invalid video buffer received
WARNING: from element /GstPipeline:pipeline0/GstVideoConvert:videoconvert0: Internal GStreamer error: code not implemented.  Please file a bug at http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer.
Additional debug info:
gstvideofilter.c(292): gst_video_filter_transform (): /GstPipeline:pipeline0/GstVideoConvert:videoconvert0:
invalid video buffer received
0:00:00.592865213  6538       0x612e80 WARN                 v4l2src gstv4l2src.c:862:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 1 - ts: 0:00:00.258184080
0:00:00.633691574  6538       0x612e80 WARN                 v4l2src gstv4l2src.c:862:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 5 - ts: 0:00:00.451559976
0:00:02.227876778  6538       0x612e80 ERROR                default video-frame.c:161:gst_video_frame_map_id: failed to map video frame plane 1
0:00:02.227940138  6538       0x612e80 WARN             videofilter gstvideofilter.c:292:gst_video_filter_transform:<videoconvert0> warning: invalid video buffer received
WARNING: from element /GstPipeline:pipeline0/GstVideoConvert:videoconvert0: Internal GStreamer error: code not implemented.  Please file a bug at http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer.
Additional debug info:
gstvideofilter.c(292): gst_video_filter_transform (): /GstPipeline:pipeline0/GstVideoConvert:videoconvert0:
invalid video buffer received
0:00:02.461239080  6538       0x612e80 WARN                 v4l2src gstv4l2src.c:862:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 5 - ts: 0:00:02.277973880
0:00:04.227961378  6538       0x612e80 ERROR                default video-frame.c:161:gst_video_frame_map_id: failed to map video frame plane 1
0:00:04.228021538  6538       0x612e80 WARN             videofilter gstvideofilter.c:292:gst_video_filter_transform:<videoconvert0> warning: invalid video buffer received
WARNING: from element /GstPipeline:pipeline0/GstVideoConvert:videoconvert0: Internal GStreamer error: code not implemented.  Please file a bug at http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer.
Additional debug info:
gstvideofilter.c(292): gst_video_filter_transform (): /GstPipeline:pipeline0/GstVideoConvert:videoconvert0:
invalid video buffer received
0:00:04.461240066  6538       0x612e80 WARN                 v4l2src gstv4l2src.c:862:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 5 - ts: 0:00:04.278040976
0:00:06.228010607  6538       0x612e80 ERROR                default video-frame.c:161:gst_video_frame_map_id: failed to map video frame plane 1
0:00:06.228074671  6538       0x612e80 WARN             videofilter gstvideofilter.c:292:gst_video_filter_transform:<videoconvert0> warning: invalid video buffer received
WARNING: from element /GstPipeline:pipeline0/GstVideoConvert:videoconvert0: Internal GStreamer error: code not implemented.  Please file a bug at http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer.
Additional debug info:
gstvideofilter.c(292): gst_video_filter_transform (): /GstPipeline:pipeline0/GstVideoConvert:videoconvert0:
invalid video buffer received
0:00:06.461304754  6538       0x612e80 WARN                 v4l2src gstv4l2src.c:862:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 5 - ts: 0:00:06.278055008
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:07.374824278
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

Hi smarttowel0,
you may try v4l2-ctl first. Looks like your v4l2src is not well functioning.

I tried v4l2-ctl:

v4l2-ctl --set-fmt-video=width=3840,height=2160,pixelformat=NV12

I can see that format set successfully with v4l2-ctl --all:

...
Video input : 0 (Camera 1: ok)
Format Video Capture:
        Width/Height      : 3840/2160
        Pixel Format      : 'NV12'
        Field             : None
        Bytes per Line    : 5760
        Size Image        : 12441600
        Colorspace        : sRGB
        Transfer Function : Default
        YCbCr Encoding    : Default
        Quantization      : Default
        Flags
...

After that I tried gstreamer and it’s not working:
gst-launch-1.0 v4l2src device=/dev/video0 ! “video/x-raw,width=3840,height=2160,format=NV12” ! fakesink
I tried YV12, YU12, NV12 pixelformats. In all cases gstreamer produced same error as in first post.

Hi smarttowel0,
You need to give exact framerate to gstreamer pipeline. Info of framerate is listed in

v4l2-ctl -d /dev/video0 --list-formats-ext

I tried 30/1, 24/1, 25/1 framerates with different pixelformats, nothing changed

v4l2-ctl -d /dev/video0 --list-formats-ext:
Index       : 2
        Type        : Video Capture
        Pixel Format: 'NV12'
        Name        : Y/CbCr 4:2:0
...
Size: Discrete 3840x2160
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.033s (29.970 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.042s (23.976 fps)
...
gst-launch-1.0 v4l2src device=/dev/video0 ! "video/x-raw,width=3840,height=2160,format=NV12,framerate=30/1" ! fakesink

Please try this command:
https://devtalk.nvidia.com/default/topic/1029392/jetson-tx2/tx2-cpu-lockup-crash-when-setting-v4l2src-state/post/5236522/#5236522

v4l2-ctl -d /dev/video0 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=100
unknown control 'bypass_mode'
v4l2-ctl -l
                     brightness (int)    : min=0 max=255 step=1 default=128 value=128
                       contrast (int)    : min=0 max=255 step=1 default=128 value=128
                     saturation (int)    : min=0 max=255 step=1 default=128 value=128
                            hue (int)    : min=0 max=255 step=1 default=0 value=0

Without bypass_mode it’s works (NV12, 3840x2160):

v4l2-ctl -d /dev/video0 --stream-mmap --stream-count=100
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.69 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.34 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.23 fps
<<<<<<<<

Please go to gstreamer forum to get help http://gstreamer-devel.966125.n4.nabble.com/

We don’t observe this kind of issue with e-con see3cam cu135. May other gstreamer experts can share experience.

Thanks

So, it’s looks like a bug in Linux kernel:
http://gstreamer-devel.966125.n4.nabble.com/Inogeni-4K-gt-USB3-0-and-Jetson-TX2-td4686007.html
https://patchwork.kernel.org/patch/7979761/

I found, that it fixed in linux version > 4.8. But L4T used 4.4 by default.
Can I upgrade my kernel to 4.8 simply with apt-get? It’s safely?

Hi smarttowel0, we suggest apply necessary patches to kernel 4.4.