【问题标题】:how to fix "GStreamer-CRITICAL **: gst_sample_get_buffer: assertion 'GST_IS_SAMPLE (sample)' failed"如何修复“GStreamer-CRITICAL **: gst_sample_get_buffer: 断言 'GST_IS_SAMPLE (sample)' 失败”
【发布时间】:2019-08-22 13:24:06
【问题描述】:

我想通过 gstreamer 抓取视频帧并显示在我的应用程序上(使用 Qt),但我遇到了一些问题:

当我尝试使用 GstAppSink (gst_app_sink_pull_sample) 时,它一直返回 NULL,我不明白。我可以完美地使用终端(gst-launch-1.0)流式传输视频。

下面是我的代码:

void gstreamer::openStream()
{
    pipeline = gst_parse_launch ("rtspsrc location=rtsp://192.168.10.123 ! rtph264depay ! h264parse ! queue ! avdec_h264 ! xvimagesink sync=false async=false appsink name=mysink", NULL);

    GstElement* sink = gst_bin_get_by_name(GST_BIN(pipeline), "mysink");

    GstAppSink* appsink = GST_APP_SINK(sink);

    if(!appsink)
    {
        qDebug() << "get app sink failed";
    }
    else
    {
        qDebug() << "app sink pass";
        mAppSink = appsink;

        openSample();
    }
}

void gstreamer::openSample()
{

    if(!mAppSink)
    {
        qDebug() << "appsink failed";
    }
    GstSample* gstSample = gst_app_sink_pull_sample(mAppSink);

    if(gstSample == NULL)
    {
        qDebug() << "sample failed ";
    }
    else{
        qDebug() << "sample pass";
    }

    GstBuffer* buffer = gst_sample_get_buffer(gstSample);
    if(!buffer)
    {
        qDebug() << "buffer fail";
    }

    GstMapInfo map;

    gst_buffer_map(buffer, &map, GST_MAP_READ);


    QImage image = QImage((map.data), 320, 240, QImage::Format_RGB888);
    emit sendFrame(image);
}

我试图在网络上找到,但几乎没有任何关于此问题的链接。

【问题讨论】:

  • xvimagesink sync=false async=false appsink name=mysink 这部分没有意义。你想要 xvimagesink 或 appsink。使用这种语法都是胡言乱语。
  • 您好,我只是想要appsink,只是用xvimagesink 测试看看有什么不同。
  • 另外,您甚至没有启动管道。每当有新样本可用时,您可能应该挂接到回调。我建议阅读 Gstreamer 的一些应用程序示例。
  • 如果我设置了 gst_element_set_state,那么流会出来,但我无法在我的应用程序上显示它。我的想法是抓取框架并显示在我的应用程序上,而不是单独显示一个窗口。
  • 这里解释太长了。您应该查看GstVideoOverlay 示例。它允许您完全做到这一点 - 在您自己的应用程序的小部件中而不是它自己的窗口中呈现视频。

标签: c++ linux qt ubuntu gstreamer


【解决方案1】:

尝试将管道更改为 “rtspsrc location=rtsp://192.168.10.123!rtph264depay!h264parse!tee name=my_tee!queue!avdec_h264!xvimagesink sync=false my_tee。!queue!appsink async=false name=mysink”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多