I am using openCV 2.4.10, Visual Studio 2010, Win 7.
I want to write a program that can split a long video into sub videos according to a special requirement. My problem now is I cannot output the video with openCV. Following is my code.
std::string inputFileName = "aa.avi";
std::string outFileName = "bb.avi";
cv::VideoCapture cap(inputFileName);
double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH);
double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
double totalFrames = cap.get(CV_CAP_PROP_FRAME_COUNT);
int frameRate = cap.get(CV_CAP_PROP_FPS);
int ex = static_cast<int>(cap.get(CV_CAP_PROP_FOURCC));
cv::Size inputSize = cv::Size((int) cap.get(CV_CAP_PROP_FRAME_WIDTH), (int) cap.get(CV_CAP_PROP_FRAME_HEIGHT));
cv::VideoWriter outCap;
if(!outCap.open(outFileName, ex, frameRate, inputSize, true))
return 0;
cv::Mat frame;
while(cap.read(frame)){
outCap << frame;
// my requirement checking
if(requirHit(frame)){
outCap.release();
return 0;
}
}
I get the following error.
Could not find encoder for codec id 28: Encoder not found
How to get the encoder I needed?
I have searched the web that may be I can use another encoder but my original task is to split the video, I don't want to change the encoding method. What can I do?