From a9abae0a92715e0909157bcf058b2eeb7872a031 Mon Sep 17 00:00:00 2001 From: Quantum Date: Thu, 26 Dec 2024 03:22:18 -0500 Subject: [PATCH] Only round end_time of removal segments We don't actually care if we chop out a segment after a keyframe, just that the next segment should start with one. So only the end_time requires rounding, not the start_time. --- test/test_postprocessors.py | 2 +- yt_dlp/postprocessor/modify_chapters.py | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/test/test_postprocessors.py b/test/test_postprocessors.py index 1ca90cd4c..8d3fac86c 100644 --- a/test/test_postprocessors.py +++ b/test/test_postprocessors.py @@ -567,7 +567,7 @@ class TestModifyChaptersPP(unittest.TestCase): ]) self.assertEqual(chapters, [ {'start_time': 0, 'end_time': 2}, - {'start_time': 3, 'end_time': 5, 'remove': True}, + {'start_time': 2, 'end_time': 5, 'remove': True}, {'start_time': 6, 'end_time': 10, 'remove': False}, ]) diff --git a/yt_dlp/postprocessor/modify_chapters.py b/yt_dlp/postprocessor/modify_chapters.py index 7eec34474..a6477451f 100644 --- a/yt_dlp/postprocessor/modify_chapters.py +++ b/yt_dlp/postprocessor/modify_chapters.py @@ -341,11 +341,6 @@ class ModifyChaptersPP(FFmpegPostProcessor): result.append(c) continue - start_frame = bisect.bisect_left(keyframes, c['start_time']) - if start_frame >= len(keyframes): - continue - - c['start_time'] = keyframes[start_frame] if c['end_time'] < keyframes[-1]: c['end_time'] = keyframes[bisect.bisect_right(keyframes, c['end_time']) - 1] result.append(c)