From e464e56115ae3f8859eb43a7200ce83ae98b821d Mon Sep 17 00:00:00 2001 From: ClosedPort22 <44864697+ClosedPort22@users.noreply.github.com> Date: Tue, 20 Aug 2024 18:48:20 +0800 Subject: [PATCH 1/3] [SubtitleConvertor] Do not attempt to convert unsupported formats --- yt_dlp/postprocessor/ffmpeg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 164c46d14..0f64a9b94 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -972,9 +972,9 @@ def run(self, info): if ext == new_ext: self.to_screen(f'Subtitle file for {new_ext} is already in the requested format') continue - elif ext == 'json': + elif ext not in self.SUPPORTED_EXTS: self.to_screen( - 'You have requested to convert json subtitles into another format, ' + f'You have requested to convert {ext} subtitles into another format, ' 'which is currently not possible') continue old_file = sub['filepath'] From 649eaf2077aff42e67b0e186a4ddcbe63f13e8f3 Mon Sep 17 00:00:00 2001 From: ClosedPort22 <44864697+ClosedPort22@users.noreply.github.com> Date: Tue, 20 Aug 2024 23:00:05 +0800 Subject: [PATCH 2/3] [SubtitleConvertor] Fix TTML conversion --- yt_dlp/postprocessor/ffmpeg.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 0f64a9b94..4f352a079 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -948,6 +948,8 @@ class FFmpegFixupDuplicateMoovPP(FFmpegCopyStreamPP): class FFmpegSubtitlesConvertorPP(FFmpegPostProcessor): SUPPORTED_EXTS = MEDIA_EXTENSIONS.subtitles + _DFXP_EXTS = ('dfxp', 'ttml', 'tt') + _SUPPORTED_INPUT_EXTS = (*SUPPORTED_EXTS, *_DFXP_EXTS) def __init__(self, downloader=None, format=None): super().__init__(downloader) @@ -972,7 +974,7 @@ def run(self, info): if ext == new_ext: self.to_screen(f'Subtitle file for {new_ext} is already in the requested format') continue - elif ext not in self.SUPPORTED_EXTS: + elif ext not in self._SUPPORTED_INPUT_EXTS: self.to_screen( f'You have requested to convert {ext} subtitles into another format, ' 'which is currently not possible') @@ -981,7 +983,7 @@ def run(self, info): sub_filenames.append(old_file) new_file = replace_extension(old_file, new_ext) - if ext in ('dfxp', 'ttml', 'tt'): + if ext in self._DFXP_EXTS: self.report_warning( 'You have requested to convert dfxp (TTML) subtitles into another format, ' 'which results in style information loss') From 44311d71264094f1f8519ee21e632fed3bc2991b Mon Sep 17 00:00:00 2001 From: ClosedPort22 <44864697+ClosedPort22@users.noreply.github.com> Date: Tue, 20 Aug 2024 23:06:21 +0800 Subject: [PATCH 3/3] [SubtitleConvertor] Fix warning for when sub file is missing --- yt_dlp/postprocessor/ffmpeg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 4f352a079..2054fdc6c 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -968,7 +968,7 @@ def run(self, info): sub_filenames = [] for lang, sub in subs.items(): if not os.path.exists(sub.get('filepath', '')): - self.report_warning(f'Skipping embedding {lang} subtitle because the file is missing') + self.report_warning(f'Skipping converting {lang} subtitle because the file is missing') continue ext = sub['ext'] if ext == new_ext: