aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Spensley <94762716+evansp@users.noreply.github.com>2022-04-21 17:26:10 -0400
committerGitHub <noreply@github.com>2022-04-21 14:26:10 -0700
commit7774db5bf9cb1d3ff1d09f0ba5d431643fdff030 (patch)
tree5a5ef5d77a97a7b8a7094114178b8b7f21e6c971
parent9b8ee23b99de91f9e463050baddfd76fa6580ad6 (diff)
downloadhypervideo-pre-7774db5bf9cb1d3ff1d09f0ba5d431643fdff030.tar.lz
hypervideo-pre-7774db5bf9cb1d3ff1d09f0ba5d431643fdff030.tar.xz
hypervideo-pre-7774db5bf9cb1d3ff1d09f0ba5d431643fdff030.zip
[EmbedThumbnail] Disable thumbnail conversion for mkv (#3512)
Closes #3209 Authored by: evansp
-rw-r--r--yt_dlp/postprocessor/embedthumbnail.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/yt_dlp/postprocessor/embedthumbnail.py b/yt_dlp/postprocessor/embedthumbnail.py
index c5ea76893..caa841b2e 100644
--- a/yt_dlp/postprocessor/embedthumbnail.py
+++ b/yt_dlp/postprocessor/embedthumbnail.py
@@ -79,12 +79,10 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
original_thumbnail = thumbnail_filename = info['thumbnails'][idx]['filepath']
- # Convert unsupported thumbnail formats to PNG (see #25687, #25717)
- # Original behavior was to convert to JPG, but since JPG is a lossy
- # format, there will be some additional data loss.
- # PNG, on the other hand, is lossless.
thumbnail_ext = os.path.splitext(thumbnail_filename)[1][1:]
- if thumbnail_ext not in ('jpg', 'jpeg', 'png'):
+ # Convert unsupported thumbnail formats (see #25687, #25717)
+ # PNG is preferred since JPEG is lossy
+ if info['ext'] not in ('mkv', 'mka') and thumbnail_ext not in ('jpg', 'jpeg', 'png'):
thumbnail_filename = convertor.convert_thumbnail(thumbnail_filename, 'png')
thumbnail_ext = 'png'
@@ -102,7 +100,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
elif info['ext'] in ['mkv', 'mka']:
options = list(self.stream_copy_opts())
- mimetype = 'image/%s' % ('png' if thumbnail_ext == 'png' else 'jpeg')
+ mimetype = 'image/%s' % ('jpeg' if thumbnail_ext in ('jpg', 'jpeg') else thumbnail_ext)
old_stream, new_stream = self.get_stream_number(
filename, ('tags', 'mimetype'), mimetype)
if old_stream is not None: