From 6f47cd63f4bd831caed8fb3103010e21df648107 Mon Sep 17 00:00:00 2001 From: Jan Scheiper Date: Sat, 13 Feb 2021 22:35:28 +0100 Subject: [PATCH] added stream stop delay --- README.md | 4 ++-- stream_stop.py | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) 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)