如何使用EMGUCV获取视频文件的帧数



我正在使用以下代码从视频文件中获取所有帧。但是,当我运行示例视频的代码时,double FramesCount1402402,并在帧#467

上弹出错误

p.s 我认为真实的帧数大约〜467,因为视频文件仅15秒(15秒 * 30fps = 〜450帧)

_capture = new Capture(OpenFile.FileName);
FramesCount = (int)_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_COUNT);
for(int i = 0; i < FramesCount - 1; i++)
{
    FramesArray.Add(_capture.QueryGrayFrame().Resize(ImageWidth, ImageHeight, Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR));
}

如何获得确切的帧数?

该代码:

int framecount = (int)Math.Floor(capt.GetCaptureProperty(CapProp.FrameCount)); //get count of frames   
double framerate = capt.GetCaptureProperty(CapProp.Fps); //get fps

如果仍然相关,对我来说很好。我喜欢21,6666667秒的视频,它返回了我正确的框架。

最新更新