Skip to content

Commit 42c2e0f

Browse files
author
arch
committed
add ffmpeg watchdog timeout to config
1 parent 6934c73 commit 42c2e0f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

funscript_editor/config/settings.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ tracking_plausibility_check: False
4141

4242
# enable logging on windows. logging cause some problems on windows only enable for debugging.
4343
logging: False
44+
45+
# timeout for an ffmpeg steam
46+
ffmpeg_timeout_in_seconds: 11

funscript_editor/data/ffmpegstream.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import numpy as np
1515

1616
from funscript_editor.utils.watchdog import Watchdog
17+
from funscript_editor.utils.config import SETTINGS
1718

1819
@dataclass
1920
class VideoInfo:
@@ -43,9 +44,10 @@ def __init__(self,
4344
skip_frames :int = 0,
4445
start_frame :int = 0,
4546
queue_size :int = 256,
46-
watchdog_timeout :int = 4,
47+
watchdog_timeout_in_seconds :int = max(( 3, int(SETTINGS['ffmpeg_timeout_in_seconds']) )),
4748
log_queue_overrun :bool = False):
4849

50+
self.watchdog_timeout_in_seconds = watchdog_timeout_in_seconds
4951
self.video_path = video_path
5052
self.config = config
5153
self.skip_frames = skip_frames
@@ -61,7 +63,7 @@ def __init__(self,
6163
self.video_info = self.get_video_info(video_path)
6264
self.frame_buffer = Queue(maxsize=queue_size)
6365

64-
self.watchdog = Watchdog(watchdog_timeout, self.watchdog_timeout)
66+
self.watchdog = Watchdog(watchdog_timeout_in_seconds, self.watchdog_timeout_callback)
6567
self.thread = Thread(target=self.run, args=())
6668
self.thread.daemon = True
6769
self.thread.start()
@@ -74,7 +76,7 @@ def __del__(self):
7476
logger = logging.getLogger(__name__)
7577

7678

77-
def watchdog_timeout(self):
79+
def watchdog_timeout_callback(self):
7880
""" Watchdog timeout for ffmpeg stream """
7981
if not self.stopped:
8082
self.logger.error("FFmpegStream Timeout")
@@ -380,7 +382,7 @@ def run(self) -> None:
380382
]
381383

382384
self.watchdog.start()
383-
self.logger.info("FFmpeg Stream Watchdog started")
385+
self.logger.info("FFmpeg Stream Watchdog started with %d sec timeout", self.watchdog_timeout_in_seconds)
384386
self.logger.info("Open FFmpeg Stream")
385387
self.pipe = sp.Popen(
386388
command,

0 commit comments

Comments
 (0)