Tutorial 13: Shoot Video with Pi Camera
Although not used in the Cookie Thief Project, I thought it would be neat to show you how to take a video recording using the Pi Camera. Normally the output file format from video capture is a raw .h264 format. I also show you how to convert this file format into something a little easier to view: a MP4.
This tutorial is a little older (published in 2015!). The main principles are still relevant, so I haven't needed to update this lesson.
import picamera from time import sleep from subprocess import call # Setup the camera with picamera.PiCamera() as camera: # Start recording camera.start_recording("pythonVideo.h264") sleep(5) # Stop recording camera.stop_recording() # The camera is now closed. print("We are going to convert the video.") # Define the command we want to execute. command = "MP4Box -add pythonVideo.h264 convertedVideo.mp4" # Execute our command call([command], shell=True) # Video converted. print("Video converted.")