I’m trying to add support for rtmpsink on the deepstream pipeline setup on my T4 instance.
I’ve already referred to the following posts: 1 2 3
And I could successfully compile the following with deepstream-app (under the sampel_apps).
static gboolean
create_rtmpsink_bin (NvDsSinkEncoderConfig * config, NvDsSinkBinSubBin * bin)
{
GstCaps *caps = NULL;
gboolean ret = FALSE;
gchar elem_name[50];
gchar encode_name[50];
uid++;
g_snprintf (elem_name, sizeof (elem_name), "sink_sub_bin%d", uid);
bin->bin = gst_bin_new (elem_name);
if (!bin->bin) {
NVGSTDS_ERR_MSG_V ("Failed to create '%s'", elem_name);
goto done;
}
g_snprintf (elem_name, sizeof (elem_name), "sink_sub_bin_queue%d", uid);
bin->queue = gst_element_factory_make (NVDS_ELEM_QUEUE, elem_name);
if (!bin->queue) {
NVGSTDS_ERR_MSG_V ("Failed to create '%s'", elem_name);
goto done;
}
g_snprintf (elem_name, sizeof (elem_name), "sink_sub_bin_transform%d", uid);
bin->transform = gst_element_factory_make (NVDS_ELEM_VIDEO_CONV, elem_name);
if (!bin->transform) {
NVGSTDS_ERR_MSG_V ("Failed to create '%s'", elem_name);
goto done;
}
g_snprintf (elem_name, sizeof (elem_name), "sink_sub_bin_cap_filter%d", uid);
bin->cap_filter = gst_element_factory_make (NVDS_ELEM_CAPS_FILTER, elem_name);
if (!bin->cap_filter) {
NVGSTDS_ERR_MSG_V ("Failed to create '%s'", elem_name);
goto done;
}
if (config->enc_type == NV_DS_ENCODER_TYPE_SW)
caps = gst_caps_from_string ("video/x-raw, format=I420");
else
caps = gst_caps_from_string ("video/x-raw(memory:NVMM), format=I420");
g_object_set (G_OBJECT (bin->cap_filter), "caps", caps, NULL);
g_snprintf (encode_name, sizeof (encode_name), "sink_sub_bin_encoder%d", uid);
switch (config->codec) {
case NV_DS_ENCODER_H264:
bin->codecparse = gst_element_factory_make ("h264parse", "h264-parser");
bin->encoder = gst_element_factory_make (NVDS_ELEM_ENC_H264_HW, encode_name);
if (config->enc_type == NV_DS_ENCODER_TYPE_SW)
bin->encoder = gst_element_factory_make (NVDS_ELEM_ENC_H264_SW, encode_name);
else
bin->encoder = gst_element_factory_make (NVDS_ELEM_ENC_H264_HW, encode_name);
break;
case NV_DS_ENCODER_H265:
bin->codecparse = gst_element_factory_make ("h265parse", "h265-parser");
if (config->enc_type == NV_DS_ENCODER_TYPE_SW)
bin->encoder = gst_element_factory_make (NVDS_ELEM_ENC_H265_SW, encode_name);
else
bin->encoder = gst_element_factory_make (NVDS_ELEM_ENC_H265_HW, encode_name);
break;
default:
goto done;
}
if (!bin->encoder) {
NVGSTDS_ERR_MSG_V ("Failed to create '%s'", encode_name);
goto done;
}
if (config->enc_type == NV_DS_ENCODER_TYPE_SW) {
//bitrate is in kbits/sec for software encoder x264enc and x265enc
g_object_set (G_OBJECT (bin->encoder), "bitrate", config->bitrate/1000, NULL);
} else {
g_object_set (G_OBJECT (bin->encoder), "bitrate", config->bitrate, NULL);
g_object_set (G_OBJECT (bin->encoder), "profile", config->profile, NULL);
g_object_set (G_OBJECT (bin->encoder), "iframeinterval", config->iframeinterval, NULL);
}
#ifdef IS_TEGRA
g_object_set (G_OBJECT (bin->encoder), "preset-level", 1, NULL);
g_object_set (G_OBJECT (bin->encoder), "insert-sps-pps", 1, NULL);
g_object_set (G_OBJECT (bin->encoder), "bufapi-version", 1, NULL);
#else
g_object_set (G_OBJECT (bin->transform), "gpu-id", config->gpu_id, NULL);
#endif
bin->flvmux = gst_element_factory_make ("flvmux", elem_name);
if (!bin->flvmux) {
NVGSTDS_ERR_MSG_V ("Failed to create '%s'", elem_name);
goto done;
}
g_object_set (G_OBJECT (bin->flvmux), "name", "mux", "streamable", TRUE, NULL);
bin->sink = gst_element_factory_make ("rtmpsink", elem_name);
if (!bin->sink) {
NVGSTDS_ERR_MSG_V ("Failed to create '%s'", elem_name);
goto done;
}
g_object_set (G_OBJECT (bin->sink), "location", config->rtmp_location, NULL);
g_print ("%s: DEBUGGER create_rtmp_sinkn \n", config->rtmp_location);
gst_bin_add_many (GST_BIN (bin->bin), bin->queue, bin->transform,
bin->encoder, bin->codecparse, bin->flvmux, bin->sink, NULL);
NVGSTDS_LINK_ELEMENT (bin->queue, bin->transform);
NVGSTDS_LINK_ELEMENT (bin->transform, bin->encoder);
NVGSTDS_LINK_ELEMENT (bin->encoder, bin->codecparse);
NVGSTDS_LINK_ELEMENT (bin->codecparse, bin->flvmux);
NVGSTDS_LINK_ELEMENT (bin->flvmux, bin->sink);
NVGSTDS_BIN_ADD_GHOST_PAD (bin->bin, bin->queue, "sink");
ret = TRUE;
if (ret != TRUE) {
g_print ("%s: start_rtmp_straming function failed\n", __func__);
}
g_print ("%s: Started streaming RTMP\n", __func__);
done:
if (caps) {
gst_caps_unref (caps);
}
if (!ret) {
NVGSTDS_ERR_MSG_V ("%s failed", __func__);
}
return ret;
}
When I start the pipeline, I get the following output:
**PERF: 29.26 (4.21)
**PERF: 0.00 (1.82)
**PERF: 0.00 (1.16)
**PERF: 0.00 (0.85)
**PERF: 0.00 (0.67)
**PERF: 0.00 (0.56)
**PERF: 0.00 (0.47)
**PERF: 0.00 (0.41)
**PERF: 0.00 (0.37)
There’s some issue with the rtmpsink as the stream can’t penetrate through the pipeline.
Any kind of help would be appreciated.
• Hardware Platform (Jetson / GPU)
T4
• DeepStream Version
5.0
• TensorRT Version
7.0.0.11