【发布时间】:2021-05-20 00:08:26
【问题描述】:
我一直在学习 GStreamer 来管理和转发从一台 RTMP 服务器到另一台服务器的流。我在尝试复制找到here 的教程时遇到了障碍,尽管没有数据缓冲区。每当我运行程序时,它都会在我设置rtmpsink URL 时停止。它不会在该行上引发错误或报告管道无法启动到ret,它只是停止。第一部分代码如下
GstElement* pipeline = nullptr;
GstBus* bus = nullptr;
GstMessage* msg = nullptr;
GstStateChangeReturn ret;
gboolean terminate = FALSE;
GstElement* source, *sink, *mux;
gst_init(&arg, &argv);
// Create Elements
source = gst_element_factory_make("rtmpsrc","source");
sink = gst_element_factory_make("rtmpsink","sink");
mux = gst_element_factory_make("flvmux", "mux");
pipeline = gst_pipeline_new("test-pipeline");
// add items to bin and
gst_bin_add_many(GST_BIN(pipeline), source, mux, sink, NULL);
if (!gst_element_link_many(source, mux, sink, NULL)) {
g_printerr("oh no");
gst_object_unref(pipeline);
return -1;
}
g_object_set(source, "location", "rtmp://localhost/live/Stream-A");
// Here is where the code stops
g_object_set(sink, "location", "rtmp://localhost/live/Stream-B");
ret = gst_element_set_state(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 -1;
}
我一直在寻找有关rtmpsink的其他问题,大多数答案都说使用flvmux来正确格式化音频和视频。
set 通话中是否有我遗漏的内容?我应该使用不同的水槽吗?
更新 1 经过更多的挖掘,我意识到我在调试错误的方式。正确使用VS后,遇到如下错误:
Exception thrown at 0x00007FF9FC2B1C3C (vcruntime140.dll)
in gstream_switch.exe: 0xC0000005: Access violation reading location
0x0000000000000000
所以看起来这只是引用未分配内存的情况。我还没有找到答案,所以我还没有标记这个答案。看其他帖子,我的猜测是可能我没有使用调试库/变量,但我不知道。
【问题讨论】:
标签: c gstreamer gstreamer-1.0