我目前正在使用NVIDIA Deepstream进行涉及GStreamer的项目。当我尝试将源元素从“ filesrc”元素更改为“ rtspsrc”元素并添加“ rtph264depay”和“ queue”时,结果是
0:00:09.533730268 19680 0x7fc02c0025e0 WARN basesrc gstbasesrc.c:2948:gst_base_src_loop:<udpsrc0> error: Internal data flow error.
0:00:09.533772178 19680 0x7fc02c0025e0 WARN basesrc gstbasesrc.c:2948:gst_base_src_loop:<udpsrc0> error: streaming task paused, reason not-linked (-1)
ERROR from element udpsrc0: Internal data flow error.
Error: Internal data flow
我认为这可能是由于“源”元素之前(TCP服务器连接)或之后(NVIDIA硬件使用元素)的代码引起的。为了测试我的方向正确,我尝试跑步
gst-launch-1.0 rtspsrc location=rtsp://192.168.0.71:8554/h264ESVideoTest ! rtph264depay ! queue ! h264parse ! avdec_h264 ! videoconvert ! videoscale ! autovideosink
设法显示了流,并同时显示了C中的等效代码,如下所示
#include <gst/gst.h>
#include <glib.h>
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End of stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *error;
gst_message_parse_error (msg, &error, &debug);
g_printerr ("ERROR from element %s: %s\n",
GST_OBJECT_NAME (msg->src), error->message);
g_free (debug);
g_printerr ("Error: %s\n", error->message);
g_error_free (error);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
int
main (int argc, char *argv[])
{
GMainLoop *loop = NULL;
GstElement *pipeline = NULL,
*source = NULL,
*rtpdepay = NULL,
*vidqueue = NULL,
*h264parser = NULL,
*decoder = NULL,
*vidconvert = NULL,
*vidscale = NULL,
*sink = NULL;
GstBus *bus = NULL;
guint bus_watch_id;
GstCaps *caps1 = NULL, *caps2 = NULL;
gulong osd_probe_id = 0;
GstPad *osd_sink_pad = NULL;
/* GStreamer initialization */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* Create gstreamer elements */
pipeline = gst_pipeline_new ("pipeline");
source = gst_element_factory_make ("rtspsrc", "file-source");
rtpdepay = gst_element_factory_make ("rtph264depay", "rtpdepay");
vidqueue = gst_element_factory_make ("queue", "vidqueue");
h264parser = gst_element_factory_make ("h264parse", "h264parser");
decoder = gst_element_factory_make ("avdec_h264", "avh264decoder");
vidconvert = gst_element_factory_make ("videoconvert", "vidconvert");
vidscale = gst_element_factory_make ("videoscale", "vidscale");
sink = gst_element_factory_make ("autovideosink", "sink");
/* Check elements creation */
if (!pipeline ||
!source ||
!rtpdepay ||
!vidqueue ||
!h264parser ||
!decoder ||
!vidconvert ||
!vidscale ||
!sink) {
g_printerr ("One or more element could not be created. Exiting.\n");
return -1;
}
/* Set input location to the source element */
g_object_set (G_OBJECT (source), "location", argv[1], NULL);
/* Add a message handler */
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* Set up the pipeline */
/* Add all elements into the pipeline */
gst_bin_add_many (GST_BIN (pipeline),
source,
rtpdepay,
vidqueue,
h264parser,
decoder,
vidconvert,
vidscale,
sink,
NULL);
/* Link the elements together */
gst_element_link_many (source,
rtpdepay,
vidqueue,
h264parser,
decoder,
vidconvert,
vidscale,
sink,
NULL);
/* Set the pipeline to "playing" state */
g_print ("Now playing: %s\n", argv[1]);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* Wait till pipeline encounters an error or EOS */
g_print ("Running...\n");
g_main_loop_run (loop);
/* Out of the main loop */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
g_source_remove (bus_watch_id);
g_main_loop_unref (loop);
return 0;
}
导致与以前相同的错误。
我给人的印象是,不需要在gst-launch-1.0
命令中进行设置的任何属性也将不需要与C代码等效的属性。是否有需要在C中设置但“ gst-launch-1.0
”自动设置的“ rtspsrc”的任何属性?还是我完全犯了另一种错误?
EDIT1: 附带的是C代码的显式错误日志
0:00:00.095045906 19967 0x7f60c401d8f0 FIXME default gstutils.c:3766:gst_pad_create_stream_id_internal:<fakesrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:00.135622983 19967 0x7f60b80031e0 WARN basesrc gstbasesrc.c:2948:gst_base_src_loop:<udpsrc1> error: Internal data flow error.
0:00:00.135662497 19967 0x7f60b80031e0 WARN basesrc gstbasesrc.c:2948:gst_base_src_loop:<udpsrc1> error: streaming task paused, reason not-linked (-1)
ERROR from element udpsrc1: Internal data flow error.
Error: Internal data flow error.
Returned, stopping playback
0:00:00.136197250 19967 0x1c9ba30 WARN rtspsrc gstrtspsrc.c:5483:gst_rtspsrc_try_send:<file-source> send interrupted
0:00:00.136228722 19967 0x1c9ba30 WARN rtspsrc gstrtspsrc.c:7552:gst_rtspsrc_pause:<file-source> PAUSE interrupted
答案 0 :(得分:0)
您应该使用“ pad-add”信号将源链接到接收器。检查以下内容:RTSP pipeline implemented via C code not working?。