【发布时间】:2013-01-05 10:54:01
【问题描述】:
我花了几个小时尝试用CvVideoWriter 编写一个 avi 文件。我总是得到一个大小为 5.54KB 且没有帧的文件。我检查了CvVideoWriter 是否不为空,也不是。我还尝试使用cvShowImage 显示我的IplImage,它显示正确。我尝试了多种编解码器(DIVX、H264、..)。
我发现当 VideoWriter 定义如下时,该函数将帧保存在 jpg 文件中:
CvVideoWriter* recorder = cvCreateVideoWriter("test0001.jpg", CV_FOURCC('I', 'Y', 'U', 'V'), -1, Size(w,h), true);
这是我的程序:
IplImage* myIplFrame=...;
CvVideoWriter* recorder = cvCreateVideoWriter("test.avi", CV_FOURCC('I', 'Y', 'U', 'V'), 10, Size(w,h), true);
cvShowImage("test",myIplFrame); //showing image properly
cvWriteFrame(recorder, myIplFrame);
cvWaitKey(500); //not helping
cvReleaseVideoWriter(&recorder);
我做错了什么?
【问题讨论】: