From c842256bbc0174f9ce840a2f8a3a0ecc64f58e3e Mon Sep 17 00:00:00 2001 From: Jonathan Baecker Date: Fri, 6 Sep 2019 12:02:11 +0200 Subject: [PATCH 1/2] fix bracket position, fix eof handling --- ffplayout.py | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/ffplayout.py b/ffplayout.py index 2883c0a5..2a0c8adf 100755 --- a/ffplayout.py +++ b/ffplayout.py @@ -337,11 +337,12 @@ def check_sync(begin, encoder): # check that we are in tolerance time if _general.stop and abs(time_distance) > _general.threshold: mailer.error( - 'Sync tolerance value exceeded with {} seconds,\n' + 'Sync tolerance value exceeded with {0:.2f} seconds,\n' 'program terminated!'.format(time_distance)) logger.error( - 'Sync tolerance value exceeded with {}, program terminated!' - ).format(time_distance) + ('Sync tolerance value exceeded with ' + '{0:.2f} seconds, program terminated!').format(time_distance) + ) encoder.terminate() sys.exit(1) @@ -478,7 +479,8 @@ def gen_filler_loop(duration): if f_dur: if f_dur > duration: # cut filler - logger.info('Generate filler with {} seconds'.format(duration)) + logger.info( + 'Generate filler with {0:.2f} seconds'.format(duration)) return ['-i', _storage.filler] + set_length( f_dur, 0, duration) else: @@ -768,9 +770,10 @@ class GetSourceIter(object): def __init__(self, encoder): self._encoder = encoder self.last_time = get_time('full_sec') + self.day_in_sec = 86400.0 if _playlist.start and 0 <= self.last_time < _playlist.start: - self.last_time += 86400 + self.last_time += self.day_in_sec self.last_mod_time = 0.0 self.json_file = None @@ -882,7 +885,7 @@ class GetSourceIter(object): elif is_float(output): self.duration = float(output) else: - self.duration = 86400 + self.duration = self.day_in_sec self.out = self.out - self.seek self.seek = 0 @@ -934,38 +937,28 @@ class GetSourceIter(object): def eof_handling(self, message, filler): self.seek = 0.0 - self.out = 20 - self.duration = 20 self.ad = False - day_in_sec = 86400.0 - ref_time = day_in_sec + ref_time = self.day_in_sec time = get_time('full_sec') if _playlist.start: - ref_time = day_in_sec + _playlist.start + ref_time = self.day_in_sec + _playlist.start if 0 <= time < _playlist.start: - time += day_in_sec + time += self.day_in_sec time_diff = self.out - self.seek + time new_len = self.out - self.seek - (time_diff - ref_time) - if new_len <= 1800: - self.out = abs(new_len) - self.duration = abs(new_len) - self.list_date = get_date(False) - self.last_mod_time = 0.0 - self.first = False - - self.last_time = 0.0 - else: - self.list_date = get_date(True) - self.last_time += self.out - self.seek + self.out = abs(new_len) + self.duration = abs(new_len) + self.list_date = get_date(False) + self.last_mod_time = 0.0 + self.first = False + self.last_time = 0.0 if filler: - self.out = day_in_sec - self.begin - self.duration = day_in_sec - self.begin self.src_cmd = gen_filler_loop(self.duration) if _storage.filler: @@ -974,7 +967,7 @@ class GetSourceIter(object): else: self.is_dummy = True else: - self.src_cmd = gen_dummy(self.out - self.seek) + self.src_cmd = gen_dummy(self.durationk) self.is_dummy = True self.set_filtergraph() @@ -1154,6 +1147,7 @@ def main(): try: for src_cmd in get_source.next(): + logger.debug('src_cmd: "{}"'.format(src_cmd)) if src_cmd[0] == '-i': current_file = src_cmd[1] else: From 74170f5c64106ea349f82a2f7f6eb942c97e870a Mon Sep 17 00:00:00 2001 From: Jonathan Baecker Date: Fri, 6 Sep 2019 12:03:46 +0200 Subject: [PATCH 2/2] better formating --- ffplayout.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ffplayout.py b/ffplayout.py index 2a0c8adf..17a93be6 100755 --- a/ffplayout.py +++ b/ffplayout.py @@ -486,8 +486,9 @@ def gen_filler_loop(duration): else: # loop filles n times loop_count = math.ceil(duration / f_dur) - logger.info('Loop filler {} times, total duration: {}'.format( - loop_count, duration)) + logger.info( + 'Loop filler {} times, total duration: {0:.2f}'.format( + loop_count, duration)) return ['-stream_loop', str(loop_count), '-i', _storage.filler, '-t', str(duration)] else: