【问题标题】:GSTREAMER - Convert the command line to C codeGSTREAMER - 将命令行转换为 C 代码
【发布时间】:2013-10-24 15:49:31
【问题描述】:

我有以下工作正常的管道:

gst-launch-1.0 -v tcpclientsrc host=192.168.1.132 port=5000  ! gdpdepay !  rtph264depay ! avdec_h264 ! videoconvert ! autovideosink

我想编写一个 C 程序来做同样的事情。

我把之前的流水线翻译成下面的代码,但是视频不启动(帮帮我)

#include <gst/gst.h>

int main(int argc, char *argv[]) {
    GstBus *bus;
    GstMessage *msg;
    GstStateChangeReturn ret;

    /* Initialize GStreamer */
    gst_init (&argc, &argv);

    GError *error = NULL;

    GstElement *pipeline = gst_parse_launch("tcpserversrc name=src ! gdpdepay ! rtph264depay ! avdec_h264 !videoconvert ! autovideosink", &error);

    if (!pipeline) {
         g_print ("Parse error: %s\n", error->message);
         exit (1);
    }

    GstElement *src = gst_bin_get_by_name(GST_BIN(pipeline), "src");
    g_object_set(src, "host", "192.168.1.132","port",5000, NULL);

// 开始播放

    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;
    }else {
         g_printerr("ERROR PLAY\n");
    }

// 等到错误或EOS

    bus = gst_element_get_bus (pipeline);
    msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

    // Parse message
    if (msg != NULL) {
        GError *err;
        gchar *debug_info;

        switch (GST_MESSAGE_TYPE (msg)) {
            case GST_MESSAGE_ERROR:
                gst_message_parse_error (msg, &err, &debug_info);
                g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message);
                g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none");
                g_clear_error (&err);
                g_free (debug_info);
                break;
            case GST_MESSAGE_EOS:
                g_print ("End-Of-Stream reached.\n");
                break;
            default:
                // We should not reach here because we only asked for ERRORs and EOS
                g_printerr ("Unexpected message received.\n");
                break;
            }
        gst_message_unref (msg);
    }

//免费资源

    gst_object_unref (bus);
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);
    return 0;
}

【问题讨论】:

    标签: stream video-streaming converter gstreamer pipeline


    【解决方案1】:

    我看不出任何明显的东西。您是否尝试过使用 GST_DEBUG="*:2" ./myapp 运行以查看是否有一些警告

    【讨论】:

      【解决方案2】:

      gdppay/gdpdepay 目前未移植到 ios 1.2 库中。我读过它应该包含在 1.3 - 1.4 版本中。我猜这就是问题所在。

      【讨论】:

        猜你喜欢
        • 2011-10-13
        • 2020-06-21
        • 1970-01-01
        • 2022-08-05
        • 2021-10-09
        • 1970-01-01
        • 2017-09-23
        • 2020-05-30
        • 1970-01-01
        相关资源
        最近更新 更多