移动端使用opencv
#include <opencv2/opencv.hpp>
int main(int argc, char* argv[]){
// 读取视频,看是否可读
cv::VideoCapture cap(InputVideoPath);
if(!cap.isOpened()){
return 0;
}
// 获取视频信息
int totalFrame = static_cast<int>(cap.get(cv::CAP_PROP_FRAME_COUNT));
double fps = cap.get(cv::CAP_PROP_FPS);
int width = static_cast<int>(cap.get(cv::CAP_PROP_FRAME_WIDTH));
int height = static_cast<int>(cap.get(cv::CAP_PROP_FRAME_HEIGHT));
// 写入帧到视频
cv::VideoWriter OutVideo;
int fourcc = cv::VideoWriter::fourcc('H', '2', '6', '4');
OutVideo.open(outputVideoPath, fourcc, fps, cv::Size(width, height));
if(!OutVideo.isOpened()){
// 可以根据需要,在增加其他fourcc格式进行判断使用,比如:MJPG等
return 0;
}
cv::Mat frame;
while(cap.read(frame)){
if(frame.empty()){
break;
}
//----------根据需要,对frame进行处理----
// 。。。。。。
//------------------------------------
OutVideo.write(frame);
}
// 释放
cap.release();
OutVideo.release();
}