# Revision history [back]

### How to write first N images of video frames

Hi, I want to write a video from a frame file. Frames folder is this:

This is my result:

And this my codes. Where is the problem?

import cv2
import numpy as np
import glob

img_array = []
height, width, layers = img.shape
size = (width,height)
img_array.append(img)

out = cv2.VideoWriter('hw.mp4',cv2.VideoWriter_fourcc(*'MP4V'), 24, size)

for i in range(len(img_array)):
out.write(img_array[i])
out.release()


### How to write first N images of video frames

Hi, I want to write a video from a frame file. Frames folder is this:

This is my result:

And this my codes. Where is the problem?

import cv2
import numpy as np
import glob
j=0
img_array = []
glob.glob('/content/drive/My Drive/M-30-HD/M-30-HD/*.jpg'): #I work on Google Colab
height, width, layers = img.shape
size = (width,height)

print(j)
j=j+1

img_array.append(img)
if(j==3000):
break

out = cv2.VideoWriter('hw.mp4',cv2.VideoWriter_fourcc(*'MP4V'), cv2.VideoWriter('m30hd.mp4',cv2.VideoWriter_fourcc(*'MP4V'), 24, size)

for i in range(len(img_array)):
out.write(img_array[i])
print(i)
out.release()