(GStreamer) 无法让 rtmpsink 正常打开?

(GStreamer) Can't get rtmpsink to open properly?

我一直在学习 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

所以看起来这只是一个引用未分配内存的例子。我还没有找到答案,所以我还没有将此标记为已回答。查看其他帖子,我的猜测是,也许我没有使用调试 libraries/variables,但我不知道。

g_object_set()需要以一个NULL参数结束表示结束,因为一次调用可以设置多个参数。

尝试:

g_object_set(source, "location", "rtmp://localhost/live/Stream-A", NULL);
g_object_set(sink, "location", "rtmp://localhost/live/Stream-B", NULL);