Python creating video from images using opencv : <p>I was trying to create a video to show the dynamic variation of the data, like just continuously showing the images one by one quickly, so I used images (the images just called 1,2,3,4,.....) and wrote the following code:</p>

<pre><code>import cv2
import numpy as np

img=[]
for i in range(0,5):
    img.append(cv2.imread(str(i)+'.png'))

height,width,layers=img[1].shape

video=cv2.VideoWriter('video.avi',-1,1,(width,height))

for j in range(0,5):
    video.write(img)

cv2.destroyAllWindows()
video.release()
</code></pre>

<p>and a error was raised:</p>

<pre><code>TypeError: image is not a numpy array, neither a scalar
</code></pre>

<p>I think I used the list in a wrong way but I'm not sure. So where did I do wrong?</p>
