【发布时间】:2020-02-19 22:37:23
【问题描述】:
当我在终端上运行以下 Gstreamer Receiver 命令时,它可以正常工作。
gst-launch-1.0 -v udpsrc 端口=5004 ! 'application/x-rtp,payload=96,encoding-name=H264' ! rtpjitterbuffer 模式=1! rtph264depay! h264解析!解码器!视频转换! 自动视频接收器
我需要捕获这些帧并使用 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