Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

These could be the potential problems:

  1. As mentioned previously, you can try different codecs and see which one works best for you. However, in my experience, all of the native codecs on your system will usually result in you having massive file sizes. Think on the scale of a Gigabyte for a couple of seconds of uncompressed video. So my solution to this is to go to: FourCC Codecs and scoll to the bottom and select the 'X264' codec and download the "FFDShow MPEG-4 Video Decoder". This codec will then be called in your code by: fourCC = cv2.VideoWriter_fourcc('X','V','I','D'). Or you can use "-1" in place of the codec flag and you can select one from the list. Using this codec results in high-quality, small size .avi files which work great in OpenCV and on most computers.
  2. This potential problem is so ridiculous because I don't see it being mentioned anywhere in the documentation. It is also go for reading in files as well. Take a look at the file path for the video you are either reading or writing to in your code. You need to change the "\" to "/" for OpenCV to read the file properly. Example: 'C:/Project/Videos/myVideo.avi'. So your code would look something like: out = cv2.VideoWriter(C:/Project/Videos/myVideo.avi', fourCC, 30, (960,720))

Hope this helps!