How to write first N images of video frames
Hi, I want to write a video from a frame file. Frames folder is this:
import cv2
import numpy as np
import glob
j=0
img_array = []
for filename in glob.glob('/content/drive/My Drive/M-30-HD/M-30-HD/*.jpg'): #I work on Google Colab
img = cv2.imread(filename)
height, width, layers = img.shape
size = (width,height)
print(j)
j=j+1
img_array.append(img)
if(j==3000):
break
out = 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()
add a comment