diff --git a/README.md b/README.md index 8901e34..3efbfb6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Octoprint ffmpeg +# Octoprint ffmpeg stream script To get started copy `constants.example.py` to `constants.py`: @@ -22,5 +22,5 @@ You can now start the stream by simply running and stop the stream with ``` -./stream_stop.py +./stream_stop.py [wait_seconds] ``` \ No newline at end of file diff --git a/stream_stop.py b/stream_stop.py index bc1eee8..da6f81e 100755 --- a/stream_stop.py +++ b/stream_stop.py @@ -1,14 +1,22 @@ #!/usr/bin/env python3 -import subprocess, os, signal +import subprocess, os, signal, sys, time from constants import * +if len(sys.argv) > 1: + wait_delay = float(sys.argv[1]) +else: + wait_delay = 0 + pid_path = os.path.join("/tmp", PIDFILE) if os.path.exists(pid_path): with open(pid_path, "r") as pid_file: kill_pid = pid_file.read().strip() + # wait the specified number of seconds + time.sleep(wait_delay) + try: os.kill(int(kill_pid), signal.SIGINT)