如何将输出视频保存到OpenCV中的文件中
我想将输出视频保存到文件中而不是显示它,并尝试使用cvcaptureimage,但仍然无法获得结果
I want to save the output video into a file instead of displaying it and tried using cvcaptureimage but still unable to get the result
#include <highgui.h>
int main(int argc, char *argv[])
{
// Create a "Capture" object from 1st command line argument
CvCapture *video = cvCaptureFromFile(argv[1]);
// this is the structure that will store the frames
IplImage *frame = NULL;
// create a window to display the video
cvNamedWindow("Video", CV_WINDOW_AUTOSIZE);
// get the next frame
while (frame = cvQueryFrame(video) )
{
// display it in the window we created
cvShowImage("Video", frame);
// wait 1000/fps milliseconds
cvWaitKey((int)(1000/cvGetCaptureProperty(video, CV_CAP_PROP_FPS)));
//reading into .avi file
CvCapture*capture=0
capture=cvcreateFileCapture(arg[1]);
if(!capture)
{
// intiate the video read
IpLImage *bgr_frame=cvQueryFrame(capture);
double fps=cvGetCaptureProperty(capture,CV_CAP_PROP_FPS);
}
}
}
我能知道我在代码中重复的错误吗?
can I know the mistake I am repeating in my code?
我知道这已经很老了,但是我不同意关于OSX的声明.
I know that this is pretty old, but I cannot agree to that statement about OSX.
您可以在OSX上轻松构建和编译FFMPEG.无需使用QTKIT/Quicktime.我实际上在OSX上编写视频,没有任何问题.
You can easily build and compile FFMPEG on OSX. No need for using QTKIT/Quicktime. I'm actually writing Video on OSX without any problems.
另一个建议是使用新的OpenCV 2.0+结构,而不要使用那些已弃用的结构. (使用Mat代替IplImage
/cvMat
,使用VideoWriter和VideoCapture.)
Another suggestion would be to use the new OpenCV 2.0+ structures instead of using those deprecated ones. (Use Mat instead of IplImage
/cvMat
, use VideoWriter and VideoCapture.)
Mat image;
VideoCapture capture;
VideoWriter out;
capture = VideoCapture(-1);
image << capture;
out.write(image);