0
我试图将视频文件的帧数保存到.txt文件中。例如将帧号(0)保存到最后一帧。我可以显示视频文件的总帧数。将总视频文件的帧数保存到.txt文件中
#include "opencv2/opencv.hpp"
#include <fstream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
// Open video file
VideoCapture video("2.avi");
double fps = video.get(CV_CAP_PROP_FPS);
double nframes = video.get(CAP_PROP_FRAME_COUNT);
cout << "Frames per second using video.get(CV_CAP_PROP_FPS) : " << fps << endl;
cout << "Frames count : " << nframes << endl;
ofstream myfile;
myfile.open ("example.txt");
for (int i=0;i<nframes;i++)
{
myfile<< "Frame Number= "<<";"<< i<< endl;
}
myfile.close();
video.release();
return 0;
}
感谢@Micka一个文件,我想帧被保存像(0,1,2 ,....)。这是我的主要问题。 – tofi
所以你想知道“当前帧数”?这也是一个财产。或者你只是数数自己。 – Micka
例如,如果我有一个500帧的视频,我想保存从0开始的帧数到4999 – tofi