我试图通过UDP协议通过网络传输RTP视频流。
以下是发件人端的管道代码:
https://gist.github.com/mgalushka/68d8ee034849a7db4f1f234e73a41405
如果我使用这样的gst-launch-1.0命令行运行接收器,我就可以接收和看到实际的视频:
gst-launch-1.0 -v udpsrc address=127.0.0.1 port=1234 caps="application/x-rtp" ! rtph263pdepay ! avdec_h263 ! autovideosink但是,当我在c代码中为同一个管道执行接收程序时,我看不到带有视频的窗口。以下是接收端的管道代码(完全--因为我相信这里有错误):
void _receive_video_init_gstreamer(NiceAgent *magent, guint stream_id, CustomData *data)
{
GstElement *pipeline, *source, *capsfilter, *videoconvert, *h263p, *rtph263pdepay, *sink;
GstBus *bus;
GstMessage *msg;
GstStateChangeReturn ret;
GSource *bus_source;
source = gst_element_factory_make ("udpsrc", "source");
rtph263pdepay = gst_element_factory_make ("rtph263pdepay", "rtph263pdepay");
h263p = gst_element_factory_make ("avdec_h263p", "h263p");
sink = gst_element_factory_make ("autovideosink", "sink");
g_object_set (source, "address", "127.0.0.1", NULL);
g_object_set (source, "port", 1234, NULL);
g_object_set (source, "caps", gst_caps_from_string("application/x-rtp"), NULL);
g_object_set (sink, "sync", FALSE, NULL);
pipeline = gst_pipeline_new ("Video receive pipeline");
if (!pipeline || !source ||
!h263p || !rtph263pdepay || !sink)
{
g_printerr ("Not all elements could be created.\n");
return;
}
gst_bin_add_many (GST_BIN (pipeline), source,
rtph263pdepay, h263p, sink, NULL);
if (gst_element_link_many (source,
rtph263pdepay, h263p, sink, NULL) != TRUE) {
g_printerr ("Elements could not be linked.\n");
gst_object_unref (pipeline);
return;
}
bus = gst_element_get_bus (pipeline);
gst_bus_enable_sync_message_emission (bus);
gst_bus_add_signal_watch (bus);
g_signal_connect (bus, "message::error",
(GCallback) on_error, NULL);
data->pipeline = pipeline;
ret = gst_element_set_state(data->pipeline, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) {
g_printerr ("Unable to set the pipeline to the playing state.\n");
gst_object_unref (pipeline);
return;
}
}从代码中收到的错误:
WARN basesrc gstbasesrc.c:2943:void gst_base_src_loop(GstPad *):<source> error: Internal data flow error.
WARN basesrc gstbasesrc.c:2943:void gst_base_src_loop(GstPad *):<source> error: streaming task paused, reason not-negotiated (-4)
ERROR default gstreamer_utils.c:42:on_error: Error received from element source: Internal data flow error.如何调试此问题?
发布于 2019-02-27 10:29:09
在构建RTP H264管道时,我也遇到了同样的警告,并且可以修复它。
gst-launch-1.0 -v udpsrc port=5004 caps="application/x-rtp,media=(string)video,encoding-name=(string)H264,payload=(int)96" ! rtpjitterbuffer ! rtph264depay ! decodebin ! videoconvert ! autovideosink随着gst的推出,一切都进行得很顺利,但在C版中,它并没有启动流。
我在日志文件中有同样的警告,并搜索“未协商”的理由。
事实证明,我的大写配置是错误的/不完整的。在您看到“未协商”的消息之前,Gstreamer将接收所有内容,并且不会抱怨。
您应该反复检查您的所有元素配置是否正确。为了找到解决方案,我不得不比较gst启动和应用程序日志消息。
顺便说一句。这是我的测试源流,我使用windows,gstreamer版本1.14.4
gst-launch-1.0 -v videotestsrc ! video/x-raw,framerate=20/1 ! videoscale ! videoconvert ! x264enc tune=zerolatency bitrate=500 speed-preset=superfast ! rtph264pay ! udpsink host=127.0.0.1 port=5004发布于 2016-06-10 06:39:12
这是太长的评论-它不是回答,而是如何分析:
试着做点文件找出不同之处。我在日志中注意到涉及opengl的东西--你需要它吗?尝试将自动视频链接更改为不使用opengl的东西。不知道您在Mac上有哪些选项(希望我猜对了)--在Linux上,我使用了ximagesink或xvimagesink。在Mac上有osxvideosink (不确定它的默认构建)--您可以检查这 ..
我的猜测是,为什么在gst发布和你的应用程序中表现不同,你的应用程序中有一些额外的开销,这会导致处理速度减慢或什么的,当一些事情被推迟时,你会得到一个未协商的错误。
我在日志中注意到了这一点:
0:00:00.608577000 29168 0x7fb5a401d850 INFO basesrc gstbasesrc.c:2838:void gst_base_src_loop(GstPad *):标记待定DISCONT
这意味着一些数据包比预期的要晚,并且被丢弃了。
尝试在udpsrc之后添加队列,这将缓冲很少的数据包:
queue = gst_element_factory_make ("queue", "srcqueue");当然,在管道和连接之间添加:
if (gst_element_link_many (source, queue
rtph263pdepay, h263p, sink, NULL) != TRUE) {https://stackoverflow.com/questions/37680843
复制相似问题