From df56f07b8311852bae4dd30479ce33c5259eb868 Mon Sep 17 00:00:00 2001 From: Jonathan Baecker Date: Wed, 29 May 2019 11:44:18 +0200 Subject: [PATCH] make tolernace value as a config option, yield onyl one list --- ffplayout.conf | 5 +++-- ffplayout.py | 15 +++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/ffplayout.conf b/ffplayout.conf index d4f59cea..49a35852 100644 --- a/ffplayout.conf +++ b/ffplayout.conf @@ -20,13 +20,14 @@ # the only way in this case is, to stop ffplayout and start it again # here we only say it can stop, the starting process is in your hand # best way is a systemd serivce on linux +# sync_tolerance: this measures the start time and if the difference exceeds this value a warning is sent # stop_threshold: stop ffplayout, if it is async in time above this value -# in copy mode this is tricky - [GENERAL] +sync_tolerance = 5 stop_on_error = True stop_threshold = 11 + # send error messages to email address, like: # missing playlist # unvalid json format diff --git a/ffplayout.py b/ffplayout.py index 25bb24d9..3bc64f08 100755 --- a/ffplayout.py +++ b/ffplayout.py @@ -50,6 +50,7 @@ else: cfg.read('ffplayout.conf') _general = SimpleNamespace( + tolerance=cfg.getint('GENERAL', 'sync_tolerance'), stop=cfg.getboolean('GENERAL', 'stop_on_error'), threshold=cfg.getfloat('GENERAL', 'stop_threshold') ) @@ -275,18 +276,12 @@ def is_int(value): def check_sync(begin, playout): time_now = get_time('full_sec') - # around 2.5 seconds is in ffmpeg buffer - tolerance = 7 - time_distance = begin - time_now if 0 <= time_now < _playlist.start and not begin == _playlist.start: time_distance -= 86400.0 - # TODO: this is only for debugging - print(time_distance) - # check that we are in tolerance time - if abs(time_distance) > tolerance: + if abs(time_distance) > _general.tolerance: mailer.warning( 'Playlist is not sync!\n{} seconds async'.format(time_distance)) logger.warning('Playlist is {} seconds async!'.format(time_distance)) @@ -871,7 +866,7 @@ class GetSourceIter(object): self.error_handling('Playlist is not valid!') if self.src_cmd is not None: - yield self.src_cmd, self.filtergraph + yield self.src_cmd + self.filtergraph def main(): @@ -926,7 +921,7 @@ def main(): get_source = GetSourceIter(playout) - for src_cmd, filtergraph in get_source.next(): + for src_cmd in get_source.next(): if src_cmd[0] == '-i': current_file = src_cmd[1] else: @@ -936,7 +931,7 @@ def main(): with Popen([ 'ffmpeg', '-v', 'error', '-hide_banner', '-nostats' - ] + src_cmd + filtergraph + ff_pre_settings, + ] + src_cmd + ff_pre_settings, stdout=PIPE) as decoder: copyfileobj(decoder.stdout, playout.stdin)