Created
June 6, 2018 14:35
-
-
Save akashjobanputra/49f6504ea99e92702bd4ee32ba9b1ddc to your computer and use it in GitHub Desktop.
Create 2 minute video clips from PiCam Raspberry Pi 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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