【问题标题】:(GStreamer) Can't get rtmpsink to open properly?(GStreamer) rtmpsink 无法正常打开?
【发布时间】: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


    【解决方案1】:

    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);
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-09
      • 1970-01-01
      • 1970-01-01
      • 2013-01-16
      • 2021-06-06
      • 1970-01-01
      相关资源
      最近更新 更多