Skip to content

Instantly share code, notes, and snippets.

@arifsuhan
Last active April 17, 2022 17:10
Show Gist options
  • Save arifsuhan/022cd9de00e413c03150f2cb4b5eeac9 to your computer and use it in GitHub Desktop.
Save arifsuhan/022cd9de00e413c03150f2cb4b5eeac9 to your computer and use it in GitHub Desktop.
import cv2
import numpy as np
from tqdm import tqdm
def gen(filename, length):
width = 720
height = 360
fps = 30
frame_n = length * fps
writer = cv2.VideoWriter(filename+".avi", cv2.VideoWriter_fourcc(*"MJPG"), fps,(width,height))
for frame in tqdm(range(frame_n)):
writer.write(np.random.randint(0, 255, (height,width,3)).astype('uint8'))
writer.release()
# gen(filename, video_in_seconds)
# gen("output", 30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment