1

我正在尝试使用opencv(视频是存储在磁盘上的 avi 文件)播放视频。但是,程序在以下行停止执行cap_ffmppeg.cpp

if(!ffmpegCapture ||
   !icvRetrieveFrame_FFMPEG_p(ffmpegCapture,&data,&step,&width,&height,&cn))
   return 0;

错误是:Access violation reading location...所以第一次capture >> frame运行时发生了段错误。

这是程序:

#include<iostream>
#include<fstream>
#include<cv.h>
#include<highgui.h>
#include<opencv2/nonfree/features2d.hpp>
using namespace std;
using namespace cv;


int main(int argc, char *argv[])
{
    if (argc <= 1)
    {
        printf("Usage: %s video\n", argv[0]);
        return -1;
    }

    VideoCapture capture(argv[1]);


    if(!capture.isOpened())
    {
        printf("Failed to open the video\n");
        return -1;
    }

    for(;;)
    {
        Mat frame;
        capture >> frame; // get a new frame from camera
    }

    return 0;
}

知道我做错了什么吗?

4

2 回答 2

1

如果您使用 x64。请使用opencv_ffmpeg245_64.dll 这个解决可能会解决问题。或者将opencv_ffmpeg245_64.dll重命名为opencv_ffmpeg245可能会解决问题。

于 2013-09-23T10:38:23.737 回答
0

原来OpenCV无法播放未压缩的视频。压缩它,一切都很好......不知道为什么存在原始问题。

于 2012-10-04T10:56:35.457 回答