擅长:python、mysql、java
<p>您没有向视频编写器提供有效的编解码器。我尝试了你的代码,但得到了一个错误,然后我改变了正在使用的编解码器,它工作了。在</p>
<p>您应该更改以下行:</p>
<pre><code>writer=cv.CreateVideoWriter("output.avi", 0, 15,(800,600) , 1)
</code></pre>
<p>为此:</p>
^{pr2}$
<p>但是<a href="https://stackoverflow.com/users/724461/andrey-kamaev">Andrey Kamaev</a>说的是你不应该使用<code>cv</code>接口是正确的,更新的<code>cv2</code>接口既简单又可靠。<a href="https://stackoverflow.com/questions/12290023/opencv-2-4-in-python-video-processing/12333066#12333066">In this question</a>我介绍了如何使用<code>cv2</code>接口将图像帧写入文件。在</p>
<p>如果上面提到的编解码器对你不起作用,恐怕你有麻烦了。您可以参考<a href="https://stackoverflow.com/questions/1136989/creating-avi-files-in-opencv/1137034#1137034">this question</a>来了解有关查找有效编解码器的更多信息。在</p>