From f9ff537b841233177ed07801b4d37017ac26e9ea Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Sat, 20 Apr 2024 08:48:49 +1000 Subject: [PATCH] restreamer: Fix a bug where playlist reports video is finished spuriously This happens when we are live viewing a stream, and the last available segment is at the end of an hour. We generate the end timestamp as being the end of the last available hour, which might be within the range of the last available segment. When this happens we stream the last segment then say we reached the requested end point. This makes the player stop asking for more segments. The fix is to pad the end time by an extra hour so we're asking for 1 hour more than the last available hour. --- restreamer/restreamer/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/restreamer/restreamer/main.py b/restreamer/restreamer/main.py index 2e33a0d..34d9c1f 100644 --- a/restreamer/restreamer/main.py +++ b/restreamer/restreamer/main.py @@ -265,12 +265,15 @@ def generate_media_playlist(channel, quality): start = dateutil.parse_utc_only(request.args['start']) if 'start' in request.args else None end = dateutil.parse_utc_only(request.args['end']) if 'end' in request.args else None if start is None or end is None: - # If start or end are not given, use the earliest/latest time available + # If start or end are not given, use the earliest/latest time available. + # For end in particular, always pad an extra hour to force a discontinuity at the end + # even if we happen to have a complete hour available. Otherwise when live streaming you + # can get an unexpected "video is complete" even though more segments are about to arrive. first, last = time_range_for_quality(channel, quality) if start is None: start = first if end is None: - end = last + end = last + datetime.timedelta(hours=1) # We still allow > 12hr ranges, but only if done explicitly (both start and end are set). if end - start > datetime.timedelta(hours=12) and ('start' not in request.args or 'end' not in request.args):