tail last 100 lines of ffmpeg logs and dump when failure detected

This commit is contained in:
Blake Blackshear
2021-01-30 07:50:17 -06:00
parent b55bd1e027
commit ee3e744cc6
2 changed files with 9 additions and 1 deletions

View File

@@ -181,6 +181,7 @@ class CameraWatchdog(threading.Thread):
now = datetime.datetime.now().timestamp()
if not self.capture_thread.is_alive():
self.logpipe.dump()
self.start_ffmpeg_detect()
elif now - self.capture_thread.current_frame.value > 20:
self.logger.info(f"No frames received from {self.camera_name} in 20 seconds. Exiting ffmpeg...")
@@ -197,6 +198,7 @@ class CameraWatchdog(threading.Thread):
poll = p['process'].poll()
if poll == None:
continue
p['logpipe'].dump()
p['process'] = start_or_restart_ffmpeg(p['cmd'], self.logger, p['logpipe'], ffmpeg_process=p['process'])
# wait a bit before checking again