From 44d47a564c7df159d3ab39aa15c7883bd10a97fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tronel?= Date: Sat, 2 Dec 2023 20:53:49 +0100 Subject: [PATCH] Make the script compatible with older version of ffmpeg. --- removeads.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/removeads.py b/removeads.py index 9ea5f1a..00192a2 100755 --- a/removeads.py +++ b/removeads.py @@ -255,7 +255,14 @@ def getFramesInStream(inputFile, begin, end, streamKind, subStreamId=0): if 'frames' in frames: frames = frames['frames'] for frame in frames: - ts = timedelta(seconds=float(frame['pts_time'])) + if 'pts_time' in frame: + pts_time = frame['pts_time'] + elif 'pkt_pts_time' in frame: + pts_time = frame['pkt_pts_time'] + else: + logger.error('Impossible to find timestamp of frame %s' % frame) + return None + ts = timedelta(seconds=pts_time)) if begin <= ts and ts <= end: res.append(frame) return res