I am using the below code to get all the frames from a video file. However, when I run the code for a sample video, double FramesCount
is 1402402
and pops an error on frame # 467
.
P.S I think the real frames count is around ~467 since the video file is only 15 seconds (15sec * 30fps = ~450 frames)
_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));
}
How can I get the exact frames count?
That code:
int framecount = (int)Math.Floor(capt.GetCaptureProperty(CapProp.FrameCount)); //get count of frames
double framerate = capt.GetCaptureProperty(CapProp.Fps); //get fps
works fine for me if still relevant. I have like 21,6666667 secs video and it return me right count of frames.