GStreamer in JP4.2.1 can't stream camera, but v4l2-ctl and ffmpeg can

Recently moved from JP3.3 to JP4.2.1 and have an analog video capture card with custom driver in my TX2 system. In 3.3 there were no issues capturing the analog video, but in 4.2.1 I get this error when launching GStreamer-

gst-launch-1.0 v4l2src device="/dev/video100" ! 'video/x-raw, width=(int)704, height=(int)480, format=(string)UYVY' ! fakesink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Device '/dev/video100' has no supported format
Additional debug info:
gstv4l2object.c(3760): gst_v4l2_object_set_format_full (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
Call to S_FMT failed for UYVY @ 704x480: Invalid argument
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

I started debugging and found that using a different format gives a different error, in this case YUYV instead of UYVY:

WARNING: erroneous pipeline: could not link v4l2src0 to fakesink0, v4l2src0 can't handle caps video/x-raw, width=(int)704, height=(int)480, format=(string)YUYV

However, using v4l2-ctl I can capture the video in either YUYV or UYVY with a command like this

v4l2-ctl --stream-mmap --stream-count=100 -d /dev/video100 --set-fmt-video=width=704,height=480,pixelformat=UYVY --stream-to=test.raw

Then play the video back using ffmpeg and the video plays fine and looks normal

ffplay -f rawvideo -video_size 704x480 -framerate 30 -pixel_format yuyv422 test-uyuv.raw

In fact I can use FFMPEG to capture the video directly to mpeg and it looks fine

ffmpeg -f video4linux2 -i /dev/video100 test.mpeg

Something about GStreamer v1.14 or the Nvidia gst plugins must have changed since V4L appears to work fine. I have tried many video caps, resolutions, and pixel formats and always get one of the two errors above. Can anyone offer suggestions on how to debug further?

Thank you,
Andy

Hi,
You may miss framerate. Please refer to this post

Hello, thanks for the suggestion. When adding in the frame rate, either 30/1 or 30000/1001 for NTSC framerate the pipeline still can not be created. All of these commands give the same errors in my first post above.

gst-launch-1.0 v4l2src device="/dev/video100" ! 'video/x-raw, width=(int)704, height=(int)480, format=(string)YUYV, framerate=(fraction)30000/1001' ! fakesink
gst-launch-1.0 v4l2src device="/dev/video100" ! 'video/x-raw, width=(int)704, height=(int)480, format=(string)UYVY, framerate=(fraction)30000/1001' ! fakesink
gst-launch-1.0 v4l2src device="/dev/video100" ! 'video/x-raw, width=(int)704, height=(int)480, format=(string)YUYV, framerate=(fraction)30/1' ! fakesink
gst-launch-1.0 v4l2src device="/dev/video100" ! 'video/x-raw, width=(int)704, height=(int)480, format=(string)UYVY, framerate=(fraction)30/1' ! fakesink

V4L2 shows that the format I’m setting should be correct

Priority: 2
Video input : 0 (Composite: ok)
Video Standard = 0x0000b000
        NTSC-M/M-JP/M-KR
Format Video Capture:
        Width/Height      : 704/480
        Pixel Format      : 'UYVY'
        Field             : Interlaced
        Bytes per Line    : 1408
        Size Image        : 675840
        Colorspace        : SMPTE 170M
        Transfer Function : Default (maps to Rec. 709)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Limited Range)
        Flags             : 
Streaming Parameters Video Capture:
        Frames per second: 29.970 (30000/1001)
        Read buffers     : 2

Any other ideas?

For anyone that finds this thread here is the solution:
The issue comes from the change in GStreamer version of 1.8.x in JP3.3 with Ubuntu 16.04 to 1.14.x in JP4.2 with Ubuntu 18.04. GStreamer no longer automatically tries interleaved video encoding due to some negative interactions with some USB cameras, so when using analog interlaced video sources the format needs to be specified in more detail

This works:

gst-launch-1.0 v4l2src device=/dev/video100 ! video/x-raw,format=UYVY,interlace-mode=interleaved ! fakesink

Source of my information:
http://gstreamer-devel.966125.n4.nabble.com/v4l2src-does-not-support-progressive-interlacing-td4688742.html

The issue is solve according to: v4l2object: Read driver selected interlace mode (#511) · Issues · GStreamer / gst-plugins-good · GitLab

However, I wish to use the released version of GStreamer and not maintain a custom version for Ubuntu 18.04.2 so I will use the explicit format string and not merge the patch into the GStreamer source for my project.

Andy

Hi,
Thanks for sharing the solution.