From 780bfd044f0d236da4db3e24f0a09b58aca48dbe Mon Sep 17 00:00:00 2001 From: Riteo Date: Wed, 14 Aug 2024 03:05:11 +0200 Subject: [PATCH] Pass target extension to all stream_copy_opts instances --- yt_dlp/postprocessor/ffmpeg.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 35f65cb5b4..cefb0430bb 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -572,7 +572,7 @@ class FFmpegVideoConvertorPP(FFmpegPostProcessor): @staticmethod def _options(target_ext): - yield from FFmpegPostProcessor.stream_copy_opts(False) + yield from FFmpegPostProcessor.stream_copy_opts(False, ext=target_ext) if target_ext == 'avi': yield from ('-c:v', 'libxvid', '-vtag', 'XVID') @@ -710,7 +710,7 @@ class FFmpegMetadataPP(FFmpegPostProcessor): @staticmethod def _options(target_ext): audio_only = target_ext == 'm4a' - yield from FFmpegPostProcessor.stream_copy_opts(not audio_only) + yield from FFmpegPostProcessor.stream_copy_opts(not audio_only, ext=target_ext) if audio_only: yield from ('-vn', '-acodec', 'copy') @@ -909,7 +909,7 @@ class FFmpegFixupStretchedPP(FFmpegFixupPostProcessor): stretched_ratio = info.get('stretched_ratio') if stretched_ratio not in (None, 1): self._fixup('Fixing aspect ratio', info['filepath'], [ - *self.stream_copy_opts(), '-aspect', f'{stretched_ratio:f}']) + *self.stream_copy_opts(ext=info['ext']), '-aspect', f'{stretched_ratio:f}']) return [], info @@ -917,7 +917,7 @@ class FFmpegFixupM4aPP(FFmpegFixupPostProcessor): @PostProcessor._restrict_to(images=False, video=False) def run(self, info): if info.get('container') == 'm4a_dash': - self._fixup('Correcting container', info['filepath'], [*self.stream_copy_opts(), '-f', 'mp4']) + self._fixup('Correcting container', info['filepath'], [*self.stream_copy_opts(ext=info['ext']), '-f', 'mp4']) return [], info @@ -940,7 +940,7 @@ class FFmpegFixupM3u8PP(FFmpegFixupPostProcessor): if self.get_audio_codec(info['filepath']) == 'aac': args.extend(['-bsf:a', 'aac_adtstoasc']) self._fixup('Fixing MPEG-TS in MP4 container', info['filepath'], [ - *self.stream_copy_opts(), *args]) + *self.stream_copy_opts(ext=info['ext']), *args]) return [], info @@ -961,7 +961,7 @@ class FFmpegFixupTimestampPP(FFmpegFixupPostProcessor): opts = ['-vf', 'setpts=PTS-STARTPTS'] else: opts = ['-c', 'copy', '-bsf', 'setts=ts=TS-STARTPTS'] - self._fixup('Fixing frame timestamp', info['filepath'], [*opts, *self.stream_copy_opts(False), '-ss', self.trim]) + self._fixup('Fixing frame timestamp', info['filepath'], [*opts, *self.stream_copy_opts(False, ext=info['ext']), '-ss', self.trim]) return [], info @@ -970,7 +970,7 @@ class FFmpegCopyStreamPP(FFmpegFixupPostProcessor): @PostProcessor._restrict_to(images=False) def run(self, info): - self._fixup(self.MESSAGE, info['filepath'], self.stream_copy_opts()) + self._fixup(self.MESSAGE, info['filepath'], self.stream_copy_opts(ext=info['ext'])) return [], info @@ -1099,7 +1099,7 @@ class FFmpegSplitChaptersPP(FFmpegPostProcessor): self.to_screen(f'Splitting video by chapters; {len(chapters)} chapters found') for idx, chapter in enumerate(chapters): destination, opts = self._ffmpeg_args_for_chapter(idx + 1, chapter, info) - self.real_run_ffmpeg([(in_file, opts)], [(destination, self.stream_copy_opts())]) + self.real_run_ffmpeg([(in_file, opts)], [(destination, self.stream_copy_opts(ext=info['ext']))]) if in_file != info['filepath']: self._delete_downloaded_files(in_file, msg=None) return [], info