Nvjpegenc segfaults when inputting RGB

Hello, I am working on a project where I would like to encode a raw RGB888 image to jpeg using GStreamer and Nvidia’s nvjpeg library. While I have gotten this to work with gstreamer’s software jpegenc element by passing in RGB raw video input, nvjpegenc seems to segfault with a “tvmrNvjpgJPEGEncoderRegisterYUVSurface 44: Surface type is not supported” when I attempt the same pipeline. For reference, the pipeline below is what I am attempting to use.

$ gst-launch-1.0 filesrc location=in.rgb ! videoparse format=rgb height=1080 width=1920 ! nvjpegenc ! filesink location=out.jpg

Any help or advice would be appreciated. Thank you so much!

If you look at the output of :

gst-inspect-1.0 nvjpegenc
....
Pad Templates:
  SINK template: 'sink'
    Availability: Always
    Capabilities:
      video/x-raw(memory:NVMM)
                 format: { (string)I420, (string)NV12 }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]
      video/x-raw
                 format: { (string)I420, (string)YV12, (string)GRAY8 }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]

you would see it only supports YUV formats for color as input, so RGB wouldn’t be a good candidate. There may be a weakness here in gstreamer negociating caps between videoparse and nvjpegenc, I’m surprized if the pipeline started.

So you just need to convert into NV12 or I420:

# CPU conversion
gst-launch-1.0 filesrc location=test.rgb ! videoparse format=rgb height=1080 width=1920 ! videoconvert ! video/x-raw,format=I420 ! nvjpegenc ! filesink location=out.jpg

# CPU for RGB->RGBA then VIC for RGBA->I420 into NVMM memory
gst-launch-1.0 filesrc location=test.rgb ! videoparse format=rgb height=1080 width=1920 ! videoconvert ! video/x-raw,format=RGBA ! nvvidconv ! 'video/x-raw(memory:NVMM),format=I420' ! nvjpegenc ! filesink location=out.jpg
1 Like

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