nvvidconv not working with RGB

I have a TX1 and am trying to get a videotestsrc in RGB into a compressed bit-stream container (UDP stream). The following pipeline works but doesn’t take advantage of the TX1 hardware optimization:

gst-launch-1.0 videotestsrc ! 'video/x-raw, format=(string)RGB, width=(int)1504, height=(int)1504, framerate=(fraction)120/1' ! videoconvert ! omxh264enc control-rate=2 bitrate=40000000 ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! rtph264pay mtu=1400 ! udpsink host=$CLIENT_IP port=5000 sync=false async=false

If I replace videoconvert with nvconvert and add (memory:NVMM), the pipeline fails.

ubuntu@tegra-ubuntu:~$ gst-launch-1.0 videotestsrc ! 'video/x-raw(memory:NVMM), format=(string)RGB, width=(int)1504, height=(int)1504, framerate=(fraction)120/1' ! nvvidconv ! omxh264enc control-rate=2 bitrate=40000000 ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! rtph264pay mtu=1400 ! udpsink host=$CLIENT_IP port=5000 sync=false async=false
WARNING: erroneous pipeline: could not link videotestsrc0 to nvvconv0

Any suggestions for how I could get this to work?
Thanks in advance for any help.

Gstreamer is a really interesting framework, there exists almost nothing online because most of the information you need is accessible using the “gst-inspect” tool. The “caps” which you’ll hear reference to means that string of text you have between videotestsrc and nvvidconv. What that does is tell the thing on the left what it should source, and the thing on the right what it should sink. Both of those modules need have those options or else you get the erroneous pipeline error.

Here’s the result of inspecting nvvidconv. Take a look at the “SINK template,” I bolded it for reference. That’s everything nvvidconv will accept, notice RGB isn’t on the list for format.

ubuntu@tegra-ubuntu:~$ gst-inspect-1.0 nvvidconv
Factory Details:
  Rank                     primary (256)
  Long-name                NvVidConv Plugin
  Klass                    Filter/Converter/Video/Scaler
  Description              Converts video from one colorspace to another & Resizes
  Author                   amit pandya <apandya@nvidia.com>

Plugin Details:
  Name                     nvvidconv
  Description              video Colorspace conversion & scaler
  Filename                 /home/ubuntu/gst_1.11.1/out/lib/gstreamer-1.0/libgstnvvidconv.so
  Version                  1.2.3
  License                  Proprietary
  Source module            gstreamer-nvvconv-plugin
  Binary package           GStreamer nvvconv Plugin
  Origin URL               http://nvidia.com/

GObject
 +----GInitiallyUnowned
       +----GstObject
             +----GstElement
                   +----GstBaseTransform
                         +----Gstnvvconv

Pad Templates:
  SRC template: 'src'
    Availability: Always
    Capabilities:
      video/x-raw(memory:NVMM)
                 format: { I420, UYVY, NV12, GRAY8, BGRx, RGBA }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]
      video/x-raw
                 format: { I420, UYVY, NV12, GRAY8, BGRx, RGBA }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]

[b]  SINK template: 'sink'
    Availability: Always
    Capabilities:
      video/x-raw(memory:NVMM)
                 format: { I420, UYVY, NV12, GRAY8, BGRx, RGBA }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]
      video/x-raw
                 format: { I420, UYVY, NV12, GRAY8, BGRx, RGBA }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ][/b]

Element Flags:
  no flags set

Element Implementation:
  Has change_state() function: 0x7f90901d78

Element has no clocking capabilities.
Element has no URI handling capabilities.

Pads:
  SINK: 'sink'
    Pad Template: 'sink'
  SRC: 'src'
    Pad Template: 'src'

Element Properties:
  name                : The name of the object
                        flags: readable, writable
                        String. Default: "nvvconv0"
  parent              : The parent of the object
                        flags: readable, writable
                        Object of type "GstObject"
  qos                 : Handle Quality-of-Service events
                        flags: readable, writable
                        Boolean. Default: false
  silent              : Produce verbose output ?
                        flags: readable, writable
                        Boolean. Default: false
  flip-method         : video flip methods
                        flags: readable, writable, controllable
                        Enum "GstNvVideoFlipMethod" Default: 0, "none"
                           (0): none             - Identity (no rotation)
                           (1): counterclockwise - Rotate counter-clockwise 90 degrees
                           (2): rotate-180       - Rotate 180 degrees
                           (3): clockwise        - Rotate clockwise 90 degrees
                           (4): horizontal-flip  - Flip horizontally
                           (5): upper-right-diagonal - Flip across upper right/lower left diagonal
                           (6): vertical-flip    - Flip vertically
                           (7): upper-left-diagonal - Flip across upper left/lower right diagonal
  tnr                 : Temporal Noise Reduction
                        flags: readable, writable, controllable
                        Enum "GstNvVideoTNRAlgos" Default: 0, "disabled"
                           (0): disabled         - TNR Disabled
                           (1): original         - TNR Original
                           (2): outdoor-low-light - TNR Outdoor Low light
                           (3): outdoor-medium-light - TNR Outdoor Medium Light
                           (4): outdoor-high-light - TNR Outdoor High Light
                           (5): indoor-low-light - TNR Indoor Low light
                           (6): indoor-medium-light - TNR Indoor Medium Light
                           (7): indoor-high-light - TNR Indoor High Light
  output-buffers      : number of output buffers
                        flags: readable, writable, changeable in NULL, READY, PAUSED or PLAYING state
                        Unsigned Integer. Range: 1 - 4294967295 Default: 4
  interpolation-method: Set interpolation methods
                        flags: readable, writable, controllable
                        Enum "GstInterpolationMethod" Default: 2, "Smart"
                           (0): Nearest          - Nearest
                           (1): Linear           - Linear
                           (2): Smart            - Smart, this is default
                           (3): Bilinear         - Bilinear
  left                : Pixels to crop at left
                        flags: readable, writable
                        Integer. Range: 0 - 2147483647 Default: 0
  right               : Pixels to crop at right
                        flags: readable, writable
                        Integer. Range: 0 - 2147483647 Default: 0
  top                 : Pixels to crop at top
                        flags: readable, writable
                        Integer. Range: 0 - 2147483647 Default: 0
  bottom              : Pixels to crop at bottom
                        flags: readable, writable
                        Integer. Range: 0 - 2147483647 Default: 0

Two issues I see. First you’re asking videotestsrc to source "video/x-raw(memory:NVMM) which it doesn’t understand. That’s just an Nvidia thing. Second you’re asking nvvidconv to sink format RGB which it doesn’t support.

Inspecting videotestsrc shows that it is capable of sourcing the following:

Pad Templates:
  SRC template: 'src'
    Availability: Always
    Capabilities:
      video/x-raw
                 format: { I420, YV12, YUY2, UYVY, VYUY, AYUV, RGBx, BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, YVYU, Y444, v210, v216, NV12, NV21, NV16, NV61, NV24, GRAY8, GRAY16_BE, GRAY16_LE, v308, IYU2, RGB16, BGR16, RGB15, BGR15, UYVP, A420, RGB8P, YUV9, YVU9, IYU1, ARGB64, AYUV64, r210, I420_10LE, I420_10BE, I422_10LE, I422_10BE, Y444_10LE, Y444_10BE, GBR, GBR_10LE, GBR_10BE, NV12_64Z32, A420_10LE, A420_10BE, A422_10LE, A422_10BE, A444_10LE, A444_10BE, P010_10LE, P010_10BE }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]
      video/x-bayer
                 format: { bggr, rggb, grbg, gbrg }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]

So we need to choose a format that can be handled by nvvidconv. Looks like your options are I420, UYVY, NV12, or RGBA.

Try this:

gst-launch-1.0 videotestsrc ! 'video/x-raw, format=(string)RGBA, width=(int)1504, height=(int)1504, framerate=(fraction)120/1' ! nvvidconv ! omxh264enc control-rate=2 bitrate=40000000 ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! rtph264pay mtu=1400 ! udpsink host=$CLIENT_IP port=5000 sync=false async=false

Sweet! I had seen the gst-inspect tool but didn’t understand what it was used for. Thanks for teaching me to fish.

Where can I find out about things not in the gst-inspect documentation? In particular, I want to know what the available options are for GstCapsFilter. I am getting the following warnings:

(clean:12045): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstCapsFilter' has no property named 'bayer'
(clean:12045): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstCapsFilter' has no property named 'YUV'
(clean:12045): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstCapsFilter' has no property named 'Ethernet'

I didn’t realize that the second input to g_object_set is a keyword, but what are the options?

g_object_set (G_OBJECT (bayer_filter), "bayer", bayer_filter_caps, NULL);
g_object_set (G_OBJECT (YUV_filter), "YUV", YUV_filter_caps, NULL);
g_object_set (G_OBJECT (Ethernet_filter), "Ethernet", Ethernet_filter_caps, NULL);

The available properties are found under gst-inspect-1.0 . In this case, the object type was capsfilter and the only properties are listed under element properties.

g_object_set (G_OBJECT (bayer_filter), "caps", bayer_filter_caps, NULL);
g_object_set (G_OBJECT (YUV_filter), "caps", YUV_filter_caps, NULL);
g_object_set (G_OBJECT (Ethernet_filter), "caps", Ethernet_filter_caps, NULL);