Skip to content

Instantly share code, notes, and snippets.

@vpatov
Created November 1, 2017 02:13
Show Gist options
  • Save vpatov/2b68d1d7de8bbad36de6e40b9b18f8c3 to your computer and use it in GitHub Desktop.
Save vpatov/2b68d1d7de8bbad36de6e40b9b18f8c3 to your computer and use it in GitHub Desktop.
import threading
def accept_connections:
while(True):
connection = server_socket.accept()[0].makefile('wb')
camera.start_recording(connection, format='h264', splitter_port=2,
resize=(640,360))
try:
camera.wait_recording(7*60*60) #assuming this records for 7 hours?
except:
pass
# create and start the connection thread
conn_thread = threading.Thread(target=accept_connections)
conn_thread.run()
# start recording video in the main thread
camera.start_recording(completed_video + '{}.h264'.format(dt.datetime.now().strftime('%Y%m%d%H%M%S') ), bitrate=4500000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment