added stream stop delay
This commit is contained in:
parent
9c2a3dc490
commit
6f47cd63f4
@ -1,4 +1,4 @@
|
|||||||
# Octoprint ffmpeg
|
# Octoprint ffmpeg stream script
|
||||||
|
|
||||||
To get started copy `constants.example.py` to `constants.py`:
|
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
|
and stop the stream with
|
||||||
|
|
||||||
```
|
```
|
||||||
./stream_stop.py
|
./stream_stop.py [wait_seconds]
|
||||||
```
|
```
|
||||||
@ -1,14 +1,22 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import subprocess, os, signal
|
import subprocess, os, signal, sys, time
|
||||||
from constants import *
|
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)
|
pid_path = os.path.join("/tmp", PIDFILE)
|
||||||
|
|
||||||
if os.path.exists(pid_path):
|
if os.path.exists(pid_path):
|
||||||
with open(pid_path, "r") as pid_file:
|
with open(pid_path, "r") as pid_file:
|
||||||
kill_pid = pid_file.read().strip()
|
kill_pid = pid_file.read().strip()
|
||||||
|
|
||||||
|
# wait the specified number of seconds
|
||||||
|
time.sleep(wait_delay)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.kill(int(kill_pid), signal.SIGINT)
|
os.kill(int(kill_pid), signal.SIGINT)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user