diff options
author | bashonly <88596187+bashonly@users.noreply.github.com> | 2023-03-08 07:10:19 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-08 13:10:19 +0000 |
commit | 01ddec7e661bf90dc4c34e6924eb9d7629886cef (patch) | |
tree | c233896797c7ac3102224948cd976598882e7997 /yt_dlp/postprocessor/ffmpeg.py | |
parent | 6f4fc5660f40f3458882a8f51601eae4af7be609 (diff) | |
download | hypervideo-pre-01ddec7e661bf90dc4c34e6924eb9d7629886cef.tar.lz hypervideo-pre-01ddec7e661bf90dc4c34e6924eb9d7629886cef.tar.xz hypervideo-pre-01ddec7e661bf90dc4c34e6924eb9d7629886cef.zip |
[postprocessor] Fix chapters if duration is not extracted (#6037)
Authored by: bashonly
Diffstat (limited to 'yt_dlp/postprocessor/ffmpeg.py')
-rw-r--r-- | yt_dlp/postprocessor/ffmpeg.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 123a95a3a..0e8f4c70b 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -302,6 +302,11 @@ class FFmpegPostProcessor(PostProcessor): None) return num, len(streams) + def _fixup_chapters(self, info): + last_chapter = traverse_obj(info, ('chapters', -1)) + if last_chapter and not last_chapter.get('end_time'): + last_chapter['end_time'] = self._get_real_video_duration(info['filepath']) + def _get_real_video_duration(self, filepath, fatal=True): try: duration = float_or_none( @@ -678,6 +683,7 @@ class FFmpegMetadataPP(FFmpegPostProcessor): @PostProcessor._restrict_to(images=False) def run(self, info): + self._fixup_chapters(info) filename, metadata_filename = info['filepath'], None files_to_delete, options = [], [] if self._add_chapters and info.get('chapters'): @@ -1040,6 +1046,7 @@ class FFmpegSplitChaptersPP(FFmpegPostProcessor): @PostProcessor._restrict_to(images=False) def run(self, info): + self._fixup_chapters(info) chapters = info.get('chapters') or [] if not chapters: self.to_screen('Chapter information is unavailable') |