Skip to content

Instantly share code, notes, and snippets.

@AO8
Created May 7, 2017 16:45
Show Gist options
  • Save AO8/f2ce3b9a1fef0cabf4edbbcd3074927f to your computer and use it in GitHub Desktop.
Save AO8/f2ce3b9a1fef0cabf4edbbcd3074927f to your computer and use it in GitHub Desktop.
Record h264 timestamped video in Python with PiCamera
from picamera import PiCamera, Color
from time import sleep
import datetime as dt
camera = PiCamera()
camera.annotate_background = Color("black")
start = dt.datetime.now()
camera.start_recording("recording.h264")
while (dt.datetime.now() - start).seconds < 3600: # total seconds for length of recording
camera.annotate_text = dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S")
camera.wait_recording(0.2)
camera.stop_recording()
camera.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment