Ask Your Question

Revision history [back]

OpenCV python .avi video doesn't work

Hello.

I have a script which uses OpenCV and python and creates a video ( avi format ) from a set of png images.

The resolution of these images is good.

The problem is that the resolution of the resulting video is very low with '1' as fourcc parameter. But if I change this parameter as cv2.VideoWriter_fourcc(*'DIVX') or as cv2.VideoWriter_fourcc('D','I','V','X') the result is an .avi video with 0KB and an error.

How can I improve the resolution and make this work?

Is the low resolution related to the images format?

CODE:

writer = cv2.VideoWriter( "C:\Users.../demo3_4.avi", -1, 1, ( width, height ) ) nFrames = 24

for i in range( 1, nFrames ): img = cv2.imread( os.path.join( str( inf ), "colorraster%d.jpg"%i ) ) writer.write( img )

cv2.destroyAllWindows()
writer.release()

Hopes you help me Thank you