Skip to content

Instantly share code, notes, and snippets.

@akashjobanputra
Created June 6, 2018 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akashjobanputra/49f6504ea99e92702bd4ee32ba9b1ddc to your computer and use it in GitHub Desktop.
Save akashjobanputra/49f6504ea99e92702bd4ee32ba9b1ddc to your computer and use it in GitHub Desktop.
Create 2 minute video clips from PiCam Raspberry Pi 3
import subprocess
import time
import os
import sys
if len(sys.argv) > 1:
directory = sys.argv[1]
else:
directory = './videos'
directory = os.path.abspath(directory)
if not os.path.exists(directory):
os.makedirs(directory)
while True:
try:
localTime = time.localtime()
filename = '{}_{}_{}_{}.h264'.format(str(localTime.tm_mday),str(localTime.tm_hour),str(localTime.tm_min), str(localTime.tm_sec))
outputFilePath = os.path.join(directory, filename)
print(filename)
command = ['raspivid', '-o', outputFilePath, '-w', '1280', '-h', '720', '-b', '8000000', '-t', '120000', '-ex', 'auto', '-n', '-awb', 'auto', '-vs']
subprocess.Popen(command)
# filename = str(localTime.tm_mday) + str(localTime.tm_mday)
time.sleep(120)
except KeyboardInterrupt as e:
print(e)
print('Quitting')
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment