首页 > 解决方案 > Gstreamer 过滤器错误导致 GST_FLOW_FLUSHING

问题描述

我正在尝试使用一个appsink,它设置为一个视频文件的uri(h264视频文件,宽度= 720,高度= 480,帧率= 30/1),将视频缓冲区传递给另一个位于GstRTSPServer管道下的appsrc在 C/C++ 中,通过 apprc 发出的需要数据信号回调。这是我设想的计算机架构

[![在此处输入图像描述][1]][1]

需求数据回调如下

static void
need_data (GstElement *appsrc, guint unused, Context *ctx)
{
    GstFlowReturn ret;
    GstSample *sample = gst_app_sink_pull_sample (GST_APP_SINK(ctx->glblapp->videosink));

    if (sample != NULL) {
        GstBuffer *buffer = gst_sample_get_buffer(sample);

        // increment the timestamp every 1/30 second
        GST_BUFFER_PTS(buffer) = ctx->timestamp;
        GST_BUFFER_DURATION (buffer) = gst_util_uint64_scale_int (1, GST_SECOND, 30);
        ctx->timestamp += GST_BUFFER_DURATION (buffer);
        g_signal_emit_by_name(appsrc, "push-buffer", buffer, &ret);

        counter++;
        g_print("Value of counter: %d \n", counter);

        if (ret != GST_FLOW_OK) {
            // something wrong, stop pushing
           g_printerr("push-buffer: GST_FLOW != OK, return value is %d\n", ret);
           g_main_loop_quit (loop);
        }
    }
}

对于我的appsrc,我已将其设置为

gst_rtsp_media_factory_set_launch (factory,
        "( appsrc name=src0 ! h264parse ! rtph264pay name=pay0 pt=96 )");

当我在 CLI 中输入以下命令时,该应用程序似乎无法显示任何视频

gst-launch-1.0 rtspsrc location=rtsp://192.168.x.x:8554/test latency=600 ! decodebin ! autovideosink

需要数据命令循环似乎在一定程度上起作用。我有一个计数器来跟踪它被调用了多少次......应用程序似乎总是在 600 次左右失败,并且返回错误是 -2 或 GS​​T_FLOW_FLUSHING(这表明 Pad 正在冲洗)

所以我想知道我的 RTSP 服务器启动过滤器错误吗?还是有其他原因?需要一些启示

谢谢[1]:https ://i.stack.imgur.com/KjTZO.png

标签: cgstreamer

解决方案


推荐阅读