OpenCV中的GStreamer API:autovideosink vs appsink

问题描述 投票:1回答:1

当我在终端上运行以下Gstreamer Receiver命令时,它可以正常工作。

gst-launch-1.0 -v udpsrc port = 5004!'应用程序/ x-rtp,有效载荷= 96,编码名称= H264'! rtpjitterbuffer模式= 1! rtph264depay! h264parse!解码器!视频转换!autovideosink

我需要使用OpenCV的Gstreamer API捕获这些帧并进行一些处理。我在C ++代码中使用了确切的管道,但是VideoCapture无法启动。代码如下:

#include <opencv2/opencv.hpp>
#include <opencv2/videoio.hpp>
using namespace cv;

#include <iostream>
using namespace std;

int main()
{
    VideoCapture cap("udpsrc port=5004 ! application/x-rtp,payload=96,encoding-name=H264 ! rtpjitterbuffer mode=1 ! rtph264depay ! h264parse ! decodebin ! videoconvert ! autovideosink", CAP_GSTREAMER);

    if (!cap.isOpened()) {
        cerr <<"VideoCapture not opened"<<endl;
        exit(-1);
    }

    while (true) {

        Mat frame;

        cap.read(frame);

        imshow("receiver", frame);

        //  Process the frame.

        if (waitKey(1) == 27) {
            break;
        }
    }

    return 0;
}

[当我尝试编译并运行时,我收到:

(Receiver_Teal:2292):GStreamer-CRITICAL **:gst_element_get_state:断言“ GST_IS_ELEMENT(元素)”失败

VideoCapture未打开

opencv c++14 ubuntu-16.04 gstreamer video-capture
1个回答
1
投票

尝试用autovideosink结尾替换appsink

VideoCapture cap("udpsrc port=5004 ! application/x-rtp,payload=96,encoding-name=H264 ! rtpjitterbuffer mode=1 ! rtph264depay ! h264parse ! decodebin ! videoconvert ! appsink", CAP_GSTREAMER);
© www.soinside.com 2019 - 2024. All rights reserved.