// CropVideo.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "opencv.hpp"
using namespace cv;
using namespace std;
int main()
{
VideoCapture cap("F:\\ImageLib\\10.mp4");
if (cap.isOpened())
cout << "Video " <<
": width=" << cap.get(CAP_PROP_FRAME_WIDTH) <<
", height=" << cap.get(CAP_PROP_FRAME_HEIGHT) <<
", nframes=" << cap.get(CAP_PROP_FRAME_COUNT) << endl;
double fps = cap.get(CAP_PROP_FPS);
VideoWriter wri("F:\\ImageLib\\temp\\10.avi", VideoWriter::fourcc('M', 'J', 'P', 'G'), fps, Size(1080, 1440));
while (1)
{
Mat frame;
cap >> frame;
if (frame.empty())
break;
Mat newFrame = frame(Rect(0, 240, 1080, 1440));
wri << newFrame;
//imshow("iopencv.com", frame);
//waitKey(10);
}
cap.release();
wri.release();
return 0;
}
OpenCV读取MP4视频裁剪部分后写成AVI视频
猜你喜欢
转载自blog.csdn.net/u014333051/article/details/79175037
今日推荐
周排行