From 4aa3c401d472816034ec41983e1109e24e78f372 Mon Sep 17 00:00:00 2001 From: Riteo Date: Fri, 8 Nov 2024 03:48:54 +0100 Subject: [PATCH] Do not pass `-map -0:s` multiple times --- yt_dlp/postprocessor/ffmpeg.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index cfcca6ef1..af98914b7 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -662,13 +662,17 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor): opts = [*self.stream_copy_opts(ext=info['ext'])] + if sub_langs and sub_names: + # We have regular subtitles available to embed. Don't copy the + # existing subtitles, we may be running the postprocessor a second + # time. + opts.extend([ + '-map', '-0:s', + ]) + for i, (lang, name) in enumerate(zip(sub_langs, sub_names)): lang_code = ISO639Utils.short2long(lang) or lang 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}', ])