以下是我目前用于计算视频长度的代码,但结果显示为:视频长度= 0;视频帧数= 271;视频的FPS = -2147483648
视频的长度为0,而视频的帧数和视频的FPS值。我包括头库,这是cmath。
CvCapture*capture=cvCaptureFromAVI("1.mp4");
int frameNumbers = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT);
int fps = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
int videoLength2 = frameNumbers/fps*(-1);
cout<<"Length of video ="<<videoLength<<endl;
cout<<"Frame Numbers of video ="<<frameNumbers<<endl;
cout<<"FPS of video ="<<fps<<endl;