擅长:python、mysql、java
<p>所以到目前为止,我找到的解决方法并没有那么有效,但它在Ubuntu 16.04上对我有效。在定期编写视频之后,我使用H264编码器再次转换它,最终的视频大小比我单独从opencv获得的要小得多。</p>
<p>以下是解决方法:</p>
<pre><code>import os # We will use it to access the terminal
# Write the video normally using mp4v and make the extension to be '.mp4'
# Note: the output using "mp4v" coder may be efficient for you, if so, you do not need to add the command below
cv2.VideoWriter('Video.mp4',cv2.VideoWriter_fourcc(*"mp4v"), NewFPS, (width,height))
# When your video is ready, just run the following command
# You can actually just write the command below in your terminal
os.system("ffmpeg -i Video.mp4 -vcodec libx264 Video2.mp4")
</code></pre>