Skip to content

Instantly share code, notes, and snippets.

@russfeld
Created June 5, 2019 17:53
Show Gist options
  • Save russfeld/97e824294cb4c67d6722c4eefc0c41e3 to your computer and use it in GitHub Desktop.
Save russfeld/97e824294cb4c67d6722c4eefc0c41e3 to your computer and use it in GitHub Desktop.
Very simple Python program to control the picam-stream script. Helpful for scripting the livestream. See https://gist.github.com/russfeld/0878b1f8eaf7409136b9125ce5e1458f
import subprocess
import time
import os
import signal
# Some trigger condition to start stream
process = subprocess.Popen("/home/pi/picam-stream.sh", preexec_fn=os.setsid, shell=True)
# Wait for some condition to stop stream
time.sleep(15)
# Stop Stream
os.killpg(os.getpgid(process.pid), signal.SIGTERM)
print("Done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment