aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/postprocessor
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/postprocessor')
-rw-r--r--yt_dlp/postprocessor/embedthumbnail.py2
-rw-r--r--yt_dlp/postprocessor/ffmpeg.py17
2 files changed, 6 insertions, 13 deletions
diff --git a/yt_dlp/postprocessor/embedthumbnail.py b/yt_dlp/postprocessor/embedthumbnail.py
index f3eb7d96d..278a45eb6 100644
--- a/yt_dlp/postprocessor/embedthumbnail.py
+++ b/yt_dlp/postprocessor/embedthumbnail.py
@@ -70,7 +70,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
self.to_screen('There aren\'t any thumbnails to embed')
return [], info
- idx = next((-(i+1) for i, t in enumerate(info['thumbnails'][::-1]) if t.get('filepath')), None)
+ idx = next((-i for i, t in enumerate(info['thumbnails'][::-1], 1) if t.get('filepath')), None)
if idx is None:
self.to_screen('There are no thumbnails on disk')
return [], info
diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py
index ea728be37..d9f816b04 100644
--- a/yt_dlp/postprocessor/ffmpeg.py
+++ b/yt_dlp/postprocessor/ffmpeg.py
@@ -853,19 +853,12 @@ class FFmpegThumbnailsConvertorPP(FFmpegPostProcessor):
return []
def convert_thumbnail(self, thumbnail_filename, target_ext):
- # NB: % is supposed to be escaped with %% but this does not work
- # for input files so working around with standard substitution
- escaped_thumbnail_filename = thumbnail_filename.replace('%', '#')
- os.rename(encodeFilename(thumbnail_filename), encodeFilename(escaped_thumbnail_filename))
- escaped_thumbnail_conv_filename = replace_extension(escaped_thumbnail_filename, target_ext)
-
- self.to_screen('Converting thumbnail "%s" to %s' % (escaped_thumbnail_filename, target_ext))
- self.run_ffmpeg(escaped_thumbnail_filename, escaped_thumbnail_conv_filename, self._options(target_ext))
-
- # Rename back to unescaped
thumbnail_conv_filename = replace_extension(thumbnail_filename, target_ext)
- os.rename(encodeFilename(escaped_thumbnail_filename), encodeFilename(thumbnail_filename))
- os.rename(encodeFilename(escaped_thumbnail_conv_filename), encodeFilename(thumbnail_conv_filename))
+
+ self.to_screen('Converting thumbnail "%s" to %s' % (thumbnail_filename, target_ext))
+ self.real_run_ffmpeg(
+ [(thumbnail_filename, ['-f', 'image2', '-pattern_type', 'none'])],
+ [(thumbnail_conv_filename.replace('%', '%%'), self._options(target_ext))])
return thumbnail_conv_filename
def run(self, info):