1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-12-20 23:18:57 +00:00

Handle cutting after last keyframe

This commit is contained in:
Quantum
2025-01-11 13:17:38 -05:00
parent 751f71a644
commit ecae8eb19f
2 changed files with 9 additions and 6 deletions

View File

@@ -42,7 +42,7 @@ class ModifyChaptersPP(FFmpegPostProcessor):
chapters += sponsor_chapters
if self._round_to_keyframes:
keyframes = self.get_keyframe_timestamps(info['filepath'])
self._round_remove_chapters(keyframes, chapters)
self._round_remove_chapters(keyframes, chapters, info.get('duration') or real_duration)
info['chapters'], cuts = self._remove_marked_arrange_sponsors(chapters)
if not cuts:
@@ -334,13 +334,16 @@ class ModifyChaptersPP(FFmpegPostProcessor):
return out_file
@staticmethod
def _round_remove_chapters(keyframes, chapters):
def _round_remove_chapters(keyframes, chapters, duration):
result = []
for c in chapters:
if not c.get('remove', False) or not keyframes:
result.append(c)
continue
if c['end_time'] > keyframes[-1] and c['end_time'] != duration:
continue
if c['end_time'] < keyframes[-1]:
c['end_time'] = keyframes[bisect.bisect_right(keyframes, c['end_time']) - 1]
result.append(c)