openCV无法在Fedora 28上播放视频

时间:2018-10-02 10:59:28

标签: fedora opencv3.0

我刚刚开始学习opencv,遇到播放视频的问题。我将qt-creator用于opencv,而我的操作系统是fedora28。

我的代码:

cv::VideoCapture vCap;
vCap.open("/home/enes/sample.mp4");
if(vCap.isOpened()){
    cv::Mat frame;
    cv::namedWindow("Video");
    for(;;){
        if(!vCap.read(frame)) break;
        cv::imshow("Video", frame);
    }
}

我的问题在下面。

Failed to query video capabilities: Inappropriate ioctl for device
libv4l2: error getting capabilities: Inappropriate ioctl for device
VIDEOIO ERROR: V4L: device /home/enes/sample.mp4: Unable to query number of channels
OpenCV(3.4.1) Error: Unspecified error (GStreamer: your gstreamer installation is missing a required plugin
) in handlemessage, file /builddir/build/BUILD/opencv-3.4.1/modules/videoio/src/cap_gstreamer.cpp, line 1869
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:

OpenCV(3.4.1) /builddir/build/BUILD/opencv-3.4.1/modules/videoio/src/cap_gstreamer.cpp:1869: error: (-2) GStreamer: your gstreamer installation is missing a required plugin
 in function handlemessage

CvCapture_OpenNI::CvCapture_OpenNI : Failed to open input file (/home/enes/sample.mp4): Bad file extension

我该怎么做才能解决此问题?谢谢。

1 个答案:

答案 0 :(得分:0)

我通过从源代码构建opencv模块,设法在Fedora 28上使用OpenCV播放MP4视频,如此处所述:Install OpenCV-Python in Fedora

在编译Open CV之前,我还安装了大多数gstreamer-plugins-*软件包并卸载了托管的OpenCV软件包。