我想将视频转换为jpg图像



我要分析视频。

我想把视频每秒转换成图像。

我的意思是如果我要分析的视频是1小时。我要编写的程序将输出3600个图像文件。

我怎样才能做到呢?

有什么解决办法吗?

最坏的情况是我必须运行视频并每秒拍摄快照。

我需要你的帮助。谢谢你。

您所需要的就是加载视频并在循环中保存单个帧。这不是一个快照,但是,你只是保存每一帧。

请注意视频的分辨率也会影响帧的处理速度。

我假设你正在使用c++。对于这一点,代码看起来像这样:

VideoCapture cap("Your_Video.mp4");
// Check if camera opened successfully
if(!cap.isOpened())
{
cout << "Error opening the video << endl;
return -1;
}
while(1)
{
Mat frame;
cap.read(frame);
if (frame.empty())
{
break;
}
// This is where you save the frame
imwrite( "Give your File Path", frame );
}
cap.release();
destroyAllWindows();
return 0;
}

最新更新