Dynamic cropping by nvvideoconvert

• Hardware Platform (Jetson / GPU) GPU
• DeepStream Version 5.0.1

Hi, my pipeline need dynamic crop size before nvstreammux.
However, sometimes it not work. Any advices? Thanks very much!

my code’s here:
GstPad* conv_src_pad = gst_element_get_static_pad(crop_conv, “src”);
gst_pad_add_probe(conv_src_pad, GST_PAD_PROBE_TYPE_IDLE, vidconv_src_pad_idle_probe, usrdata, NULL);
gst_object_unref(conv_src_pad);

in vidconv_src_pad_idle_probe
gchar src_crop[32] = { };
g_snprintf(src_crop, 31, “%u:%u:%u:%u”, x, y, w, h);
GstPad* conv_src_pad = gst_element_get_static_pad(crop_conv, “src”);
GstPad* queue_sink_pad = gst_element_get_static_pad(src_queue, “sink”);
if (!gst_pad_unlink(conv_src_pad, queue_sink_pad))
{
NVGSTDS_ERR_MSG_V(“Failed to unlink pad ‘%s’”, elem_name);
}
gst_element_set_state(crop_conv, GST_STATE_READY);
g_object_set(G_OBJECT(crop_conv), “src-crop”, src_crop, NULL);
if (gst_pad_link(conv_src_pad, queue_sink_pad) != GST_PAD_LINK_OK)
{
NVGSTDS_ERR_MSG_V(“Failed to link pad ‘%s’”, elem_name);
}
gst_element_set_state(crop_conv, GST_STATE_PLAYING);
gst_pad_add_probe(queue_sink_pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, consume_eos_prop, NULL, NULL);

What will happen if you set property directly without unlinking/linking the pad and changing the element state?

Hi, Fiona.Chen
The property src-crop would not take effects!

By gst-inspect-1.0 nvvideoconvert

It shows src-crop could only been changed when element state at GST_STATE_READY or NULL

For change state, it is better to set state first and then check the state of the return value to decide whether it is the right state to unlink pad.

However, there’s no return value for set state, and the value can be set, but the frame was not cropped. no effects applied.

gst_element_get_state can be used to confirm that the state change has finished.