首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复"GStreamer-CRITICAL **:gst_sample_get_buffer: assertion 'GST_IS_SAMPLE (sample)‘失败“

如何修复"GStreamer-CRITICAL **:gst_sample_get_buffer: assertion 'GST_IS_SAMPLE (sample)‘失败“
EN

Stack Overflow用户
提问于 2019-04-01 19:30:06
回答 1查看 1.5K关注 0票数 0

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

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

下面是我的代码:

代码语言:javascript
复制
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);
}

我试着在网上寻找,但几乎没有任何关于这个问题的链接。

EN

回答 1

Stack Overflow用户

发布于 2020-10-31 04:03:32

尝试将管道更改为"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“

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55454086

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档