From 62e274f515e293cd9926a2baa29a2f903df43cb8 Mon Sep 17 00:00:00 2001 From: Riteo Date: Wed, 14 Aug 2024 02:01:08 +0200 Subject: [PATCH] Move regular subtitles options to their loop --- yt_dlp/postprocessor/ffmpeg.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 6fa133729..d986d12b8 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -654,17 +654,19 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor): input_files = [filename, *sub_filenames] - opts = [ - *self.stream_copy_opts(ext=info['ext']), - # Don't copy the existing subtitles, we may be running the - # postprocessor a second time - '-map', '-0:s', - ] + opts = [*self.stream_copy_opts(ext=info['ext'])] for i, (lang, name) in enumerate(zip(sub_langs, sub_names)): - opts.extend(['-map', f'{i + 1}:0']) lang_code = ISO639Utils.short2long(lang) or lang - opts.extend([f'-metadata:s:s:{i}', f'language={lang_code}']) + opts.extend([ + # Don't copy the existing subtitles, we may be running the + # postprocessor a second time + '-map', '-0:s', + + '-map', f'{i + 1}:0', + f'-metadata:s:s:{i}', f'language={lang_code}' + ]) + if name: opts.extend([f'-metadata:s:s:{i}', f'handler_name={name}', f'-metadata:s:s:{i}', f'title={name}'])