Skip to content

Instantly share code, notes, and snippets.

@FirefoxMetzger
Created March 5, 2021 04:43
Show Gist options
  • Save FirefoxMetzger/bb2da9d8cd824902be550da0e28f0c1f to your computer and use it in GitHub Desktop.
Save FirefoxMetzger/bb2da9d8cd824902be550da0e28f0c1f to your computer and use it in GitHub Desktop.
import imageio as iio
import matplotlib.pyplot as plt
import time
camera = iio.get_reader("<video0>")
meta = camera.get_meta_data()
num_frames = 5 * int(meta["fps"])
delay = 1/meta["fps"]
buffer = list()
for frame_counter in range(num_frames):
frame = camera.get_next_data()
buffer.append(frame)
time.sleep(delay)
camera.close()
iio.mimwrite("frames.mp4", buffer, macro_block_size=8, fps=meta["fps"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment