Please provide complete information as applicable to your setup.
• Hardware Platform (GPU): dGPU
• DeepStream Version : 6.0
• Issue Type( questions, new requirements, bugs) : I am trying to use nvvideoconvert in create_rtsp_src_bin() in deepstream_source_bin.c to crop a portion of incoming frame and pass that ahead in the pipeline.I have tried flipping the frame using flip-method property of nvvideoconvert and that works fine but when I use src-crop and dest-crop to crop the frame, it doesn’t works and same original frame is flowing in the pipeline . I also tried making changes to size of caps_filter but it gives 0 fps. Attached my code below.
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description): To use nvvideoconvert plugin in create_rtsp_src_bin() to crop incoming to frames to a particular ROI.
**This is the code I am using: **
static gboolean
create_rtsp_src_bin (NvDsSourceConfig * config, NvDsSrcBin * bin)
{
NvDsSRContext *ctx = NULL;
gboolean ret = FALSE;
gchar elem_name[50];
bin->config = config;
GstCaps *caps = NULL;
GstCapsFeatures *feature = NULL;
bin->latency = config->latency;
bin->rtsp_reconnect_interval_sec = config->rtsp_reconnect_interval_sec;
bin->rtsp_reconnect_attempts = config->rtsp_reconnect_attempts;
bin->num_rtsp_reconnects = 0;
g_snprintf (elem_name, sizeof (elem_name), "src_elem%d", bin->bin_id);
bin->src_elem = gst_element_factory_make ("rtspsrc", elem_name);
if (!bin->src_elem) {
NVGSTDS_ERR_MSG_V ("Failed to create '%s'", elem_name);
goto done;
}
g_signal_connect (G_OBJECT(bin->src_elem), "select-stream",
G_CALLBACK(cb_rtspsrc_select_stream),
bin);
g_object_set (G_OBJECT (bin->src_elem), "location", config->uri, NULL);
g_object_set (G_OBJECT (bin->src_elem), "latency", config->latency, NULL);
g_object_set (G_OBJECT (bin->src_elem), "drop-on-latency", TRUE, NULL);
configure_source_for_ntp_sync (bin->src_elem);
// 0x4 for TCP and 0x7 for All (UDP/UDP-MCAST/TCP)
if ((config->select_rtp_protocol == GST_RTSP_LOWER_TRANS_TCP)
|| (config->select_rtp_protocol == (GST_RTSP_LOWER_TRANS_UDP |
GST_RTSP_LOWER_TRANS_UDP_MCAST | GST_RTSP_LOWER_TRANS_TCP))) {
g_object_set (G_OBJECT (bin->src_elem), "protocols",
config->select_rtp_protocol, NULL);
GST_DEBUG_OBJECT (bin->src_elem,
"RTP Protocol=0x%x (0x4=TCP and 0x7=UDP,TCP,UDPMCAST)----\n",
config->select_rtp_protocol);
}
g_signal_connect (G_OBJECT (bin->src_elem), "pad-added",
G_CALLBACK (cb_newpad3), bin);
g_snprintf (elem_name, sizeof (elem_name), "tee_rtsp_elem%d", bin->bin_id);
bin->tee_rtsp_pre_decode = gst_element_factory_make ("tee", elem_name);
if (!bin->tee_rtsp_pre_decode) {
NVGSTDS_ERR_MSG_V ("Failed to create '%s'", elem_name);
goto done;
}
g_snprintf (elem_name, sizeof (elem_name), "tee_rtsp_post_decode_elem%d", bin->bin_id);
bin->tee_rtsp_post_decode = gst_element_factory_make ("tee", elem_name);
if (!bin->tee_rtsp_post_decode) {
NVGSTDS_ERR_MSG_V ("Failed to create '%s'", elem_name);
goto done;
}
if (config->smart_record) {
NvDsSRInitParams params = {0};
params.containerType = (NvDsSRContainerType) config->smart_rec_container;
if (config->file_prefix)
params.fileNamePrefix = g_strdup_printf ("%s_%d", config->file_prefix, config->camera_id);
params.dirpath = config->dir_path;
params.cacheSize = config->smart_rec_cache_size;
params.defaultDuration = config->smart_rec_def_duration;
params.callback = smart_record_callback;
if (NvDsSRCreate (&ctx, ¶ms) != NVDSSR_STATUS_OK) {
NVGSTDS_ERR_MSG_V ("Failed to create smart record bin");
g_free (params.fileNamePrefix);
goto done;
}
g_free (params.fileNamePrefix);
gst_bin_add (GST_BIN(bin->bin), ctx->recordbin);
bin->recordCtx = (gpointer) ctx;
}
g_snprintf (elem_name, sizeof (elem_name), "dec_que%d", bin->bin_id);
bin->dec_que = gst_element_factory_make ("queue", elem_name);
if (!bin->dec_que) {
NVGSTDS_ERR_MSG_V ("Failed to create '%s'", elem_name);
goto done;
}
if (bin->rtsp_reconnect_interval_sec > 0) {
NVGSTDS_ELEM_ADD_PROBE (bin->rtspsrc_monitor_probe, bin->dec_que,
"sink", rtspsrc_monitor_probe_func,
GST_PAD_PROBE_TYPE_BUFFER,
bin);
install_mux_eosmonitor_probe = TRUE;
} else {
NVGSTDS_ELEM_ADD_PROBE (bin->rtspsrc_monitor_probe, bin->dec_que,
"sink", rtspsrc_monitor_probe_func,
GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
bin);
}
g_snprintf (elem_name, sizeof (elem_name), "decodebin_elem%d", bin->bin_id);
bin->decodebin = gst_element_factory_make ("decodebin", elem_name);
if (!bin->decodebin) {
NVGSTDS_ERR_MSG_V ("Failed to create '%s'", elem_name);
goto done;
}
g_signal_connect (G_OBJECT (bin->decodebin), "pad-added",
G_CALLBACK (cb_newpad2), bin);
g_signal_connect (G_OBJECT (bin->decodebin), "child-added",
G_CALLBACK (decodebin_child_added), bin);
g_snprintf (elem_name, sizeof (elem_name), "src_que%d", bin->bin_id);
bin->cap_filter = gst_element_factory_make (NVDS_ELEM_QUEUE, elem_name);
if (!bin->cap_filter) {
NVGSTDS_ERR_MSG_V ("Failed to create '%s'", elem_name);
goto done;
}
g_mutex_init (&bin->bin_lock);
if (config->dewarper_config.enable) {
if (!create_dewarper_bin (&config->dewarper_config, &bin->dewarper_bin)) {
g_print ("Failed to create dewarper bin \n");
goto done;
}
gst_bin_add_many (GST_BIN (bin->bin), bin->src_elem,
bin->tee_rtsp_pre_decode,
bin->dec_que,
bin->decodebin,
bin->cap_filter,
bin->tee_rtsp_post_decode,
bin->dewarper_bin.bin,
NULL);
}else{
g_snprintf(elem_name, sizeof(elem_name), "nvvidconv_elem%d", bin->bin_id);
bin->nvvidconv = gst_element_factory_make(NVDS_ELEM_VIDEO_CONV, elem_name);
if (!bin->nvvidconv)
{
NVGSTDS_ERR_MSG_V("Could not create element 'nvvidconv_elem'");
goto done;
}
//-------------------------------------------------------------------------------------------------------------
//g_object_set (G_OBJECT (bin->nvvidconv), "flip-method", videoConvCtx.flipMethod, NULL);
g_object_set (G_OBJECT (bin->nvvidconv), "src-crop", "500:400:504:504", NULL);
g_object_set (G_OBJECT (bin->nvvidconv), "dest-crop", "0:0:504:504", NULL);
caps = gst_caps_new_simple ("video/x-raw",
"width", G_TYPE_INT, 504,
"height", G_TYPE_INT, 504, NULL);
feature = gst_caps_features_new("memory:NVMM", NULL);
//-------------------------------------------------------------------------------------------------------------
bin->cap_filter1 =
gst_element_factory_make(NVDS_ELEM_CAPS_FILTER, "src_cap_filter_nvvidconv");
if (!bin->cap_filter1)
{
NVGSTDS_ERR_MSG_V("Could not create 'queue'");
goto done;
}
g_object_set(G_OBJECT(bin->cap_filter1), "caps", caps, NULL);
gst_caps_unref(caps);
gst_bin_add_many(GST_BIN(bin->bin), bin->src_elem,
bin->tee_rtsp_pre_decode,
bin->dec_que,
bin->decodebin,
bin->cap_filter,
bin->tee_rtsp_post_decode,
bin->nvvidconv, bin->cap_filter1,
NULL);
}
link_element_to_tee_src_pad(bin->tee_rtsp_pre_decode, bin->dec_que);
NVGSTDS_LINK_ELEMENT (bin->dec_que, bin->decodebin);
if (ctx)
link_element_to_tee_src_pad(bin->tee_rtsp_pre_decode, ctx->recordbin);
NVGSTDS_LINK_ELEMENT (bin->cap_filter, bin->tee_rtsp_post_decode);
if (config->dewarper_config.enable) {
link_element_to_tee_src_pad (bin->tee_rtsp_post_decode, bin->dewarper_bin.bin);
NVGSTDS_BIN_ADD_GHOST_PAD (bin->bin, bin->dewarper_bin.bin, "src");
} else{
link_element_to_tee_src_pad(bin->tee_rtsp_post_decode, bin->nvvidconv);
NVGSTDS_LINK_ELEMENT (bin->nvvidconv, bin->cap_filter1);
NVGSTDS_BIN_ADD_GHOST_PAD (bin->bin, bin->cap_filter1, "src");
}
ret = TRUE;
g_timeout_add (1000, watch_source_status, bin);
// Enable local start / stop events in addition to the one
// received from the server.
#if 0
if (config->smart_record == 2) {
if (bin->config->smart_rec_interval)
g_timeout_add (bin->config->smart_rec_interval * 1000, smart_record_event_generator, bin);
else
g_timeout_add (10000, smart_record_event_generator, bin);
}
#endif
GST_CAT_DEBUG (NVDS_APP,
"Decode bin created. Waiting for a new pad from decodebin to link");
done:
if (!ret) {
NVGSTDS_ERR_MSG_V ("%s failed", __func__);
}
return ret;
}
As I am new to gstreamer, please guide if there’s something wrong with my code.