The following code shows, how to count the video frames in an AVI file.
Example
#include "cv.h" #include <iostream> #include "highgui.h" using namespace std; int main( int argc, char* argv[] ) { CvCapture *capture = cvCaptureFromAVI( "Megamind.avi"); cvQueryFrame( capture ); int nFrames = (int) cvGetCaptureProperty( capture , CV_CAP_PROP_FRAME_COUNT ); std::cout<<"frames :"<<nFrames; getchar(); return(0); }