How to convert bayer raw10 to H.264 using GStreamer?

I’m trying to create a gstreamer pipeline to transcode bayer raw10 frames to H.264 using appsrc. Here’s what my pipeline looks like:

r#"appsrc name=src is-live=true block=true caps="video/x-bayer,format=bggr10,framerate=10/1,width=1920,height=1080" !
                        bayer2rgb !
                        videoconvert !
                        video/x-raw,format=NV12,width=1920,height=1080 !
                        nvvidconv !
                        video/x-raw(memory:NVMM),format=NV12,width=1920,height=1080 !
                        nvv4l2h264enc insert-sps-pps=true maxperf-enable=1 !
                        h264parse !
                        appsink name=sink emit-signals=true sync=false caps="video/x-h264,stream-format=byte-stream""#

But I keep getting a caps non-negotiated error from GStreamer:

[ERROR farm_ng_stream::video::stream_decoder] Error { structure: Some(GstMessageError { gerror: (GError) ((GError*) 0xffff84022aa0), debug: (gchararray) "gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline1/GstAppSrc:src:\nstreaming stopped, reason not-negotiated (-4)", details: Structure(details { flow-return: (gint) -4 }) }), source: Some((Object { inner: TypedObjectRef { inner: 0xffff9823bd90, type: GstAppSrc } }, "src")), error: Error { domain: gst-stream-error-quark, code: 1, message: "Internal data stream error." }, debug: Some("gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline1/GstAppSrc:src:\nstreaming stopped, reason not-negotiated (-4)"), details: Some(details { flow-return: (gint) -4 }) }

For context, I’m trying to run this from a NVIDIA Jetson Xavier, using Jetpack 5.1.1 I have a luxonis oak-d camera and this is my depthai pipeline:

void add_to_pipeline_rgb(
    std::shared_ptr<dai::Pipeline> pipeline,
    ColorStreamOptions const &options,
    bool data_campaign) {

  auto xout_rgb = pipeline->create<dai::node::XLinkOut>();
  xout_rgb->setStreamName(std::string(options.queue_name));

  auto cam = pipeline->create<dai::node::ColorCamera>();

  cam->setBoardSocket(to_camera_board_socket(options.camera_board_socket));
  cam->setResolution(to_sensor_resolution(options.resolution));
  cam->setFps(options.fps);

  if (data_campaign) {
    cam->setRawOutputPacked(true); // Ensure raw output is packed
    cam->raw.link(xout_rgb->input);
  } else {
      auto encoder = pipeline->create<dai::node::VideoEncoder>();

      encoder->setDefaultProfilePreset(
          30, to_encoder_profile(options.encoder_options.profile));
      encoder->setBitrateKbps(options.encoder_options.cbr_preferred_bitrate_kbps);
      encoder->setRateControlMode(
          to_rate_control_mode(options.encoder_options.rate_control_mode));
      encoder->setQuality(options.encoder_options.vbr_or_mjpeg_quality);
      encoder->setKeyframeFrequency(options.encoder_options.frames_per_keyframe);

      cam->video.link(encoder->input);
      encoder->bitstream.link(xout_rgb->input);

    auto xin_control = pipeline->create<dai::node::XLinkIn>();
    xin_control->setStreamName(std::string(options.queue_name) + "/control");
    xin_control->out.link(cam->inputControl);
  }
}

For this particular case data_campaing = true

I am confident I’m outputing bayer raw10 frames. Additionally, if I try to run my pipeline via CLI I get no errors:

GST_DEBUG=3 gst-launch-1.0 -v \
appsrc name=src is-live=true block=true caps="video/x-bayer,format=bggr10,framerate=10/1,width=1920,height=1080" ! \
bayer2rgb ! videoconvert ! video/x-raw,format=NV12,width=1920,height=1080 ! \
nvvidconv ! "video/x-raw(memory:NVMM),format=NV12,width=1920,height=1080" ! \
nvv4l2h264enc insert-sps-pps=true maxperf-enable=1 ! \
h264parse ! \
appsink name=sink emit-signals=true caps="video/x-h264,stream-format=byte-stream" sync=false

This is my first time ever using GStreamer, so I’m not too sure if there’s anything obvious I’m missing. Any help is greatly appreciated!

I have tried specifying caps, supressing caps, but had no success.

I expect to be able to output H.264 frames.

Hi,
The hardware VIC engine does not support the conversion. Please try the software plugins and see if it works:

r#"appsrc name=src is-live=true block=true caps="video/x-bayer,format=bggr10,framerate=10/1,width=1920,height=1080" !
                        bayer2rgb !
                        videoconvert !
                        video/x-raw,format=I420,width=1920,height=1080 !
                        x264enc !
                        h264parse !
                        appsink name=sink emit-signals=true sync=false caps="video/x-h264,stream-format=byte-stream""#

Hi Daniel,

Thank you very much for replying.

However, unfortunately, the proposed solution did not work:

[ERROR farm_ng_stream::video::stream_decoder] Error { structure: Some(GstMessageError { gerror: (GError) ((GError*) 0xffff6c004420), debug: (gchararray) "gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstAppSrc:src:\nstreaming stopped, reason not-negotiated (-4)", details: Structure(details { flow-return: (gint) -4 }) }), source: Some((Object { inner: TypedObjectRef { inner: 0xffff9c23fe10, type: GstAppSrc } }, "src")), error: Error { domain: gst-stream-error-quark, code: 1, message: "Internal data stream error." }, debug: Some("gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstAppSrc:src:\nstreaming stopped, reason not-negotiated (-4)"), details: Some(details { flow-return: (gint) -4 }) }
0:00:09.423921713 1648476 0xffff9c018360 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<src> error: Internal data stream error.
0:00:09.424105106 1648476 0xffff9c018360 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<src> error: streaming stopped, reason not-negotiated (-4)

Hi,
Please run $ gst-inspect-1.0 bayer2rgb and check the supported formats. It looks like the format should be set to bggr instead of bggr10?

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