Skip to content

Instantly share code, notes, and snippets.

@kevinlinxc
Created October 14, 2023 23:20
Show Gist options
  • Save kevinlinxc/b6ce924182b3483a834e9db215b3e685 to your computer and use it in GitHub Desktop.
Save kevinlinxc/b6ce924182b3483a834e9db215b3e685 to your computer and use it in GitHub Desktop.
Simple OpenCV video genereator where each frame is the frame number
import cv2
import numpy
# make a video where each frame is the frame number
writer = cv2.VideoWriter("frame_numbers.mp4", cv2.VideoWriter_fourcc(*"mp4v"), 30, (1920, 1080))
for i in range(6572):
frame = numpy.zeros((1080, 1920, 3), dtype=numpy.uint8)
cv2.putText(frame, str(i), (500, 500), cv2.FONT_HERSHEY_SIMPLEX, 10, (255, 255, 255), 2)
writer.write(frame)
print(i, end="\r")
writer.release()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment