]> jfr.im git - yt-dlp.git/commitdiff
[postprocessor/embedthumbnail] Add conversion for non JPG/PNG images
authorAlex Merkel <redacted>
Thu, 18 Jun 2020 20:36:44 +0000 (22:36 +0200)
committerAlex Merkel <redacted>
Thu, 18 Jun 2020 20:36:44 +0000 (22:36 +0200)
youtube_dl/postprocessor/embedthumbnail.py

index 56be914b8f1b6e98802163ae1013392079d93fb3..a5939a7d318079161acf57f145d78c67fe3b363d 100644 (file)
@@ -41,6 +41,16 @@ def run(self, info):
                 'Skipping embedding the thumbnail because the file is missing.')
             return [], info
 
+        if not os.path.splitext(encodeFilename(thumbnail_filename))[1].lower() in ['.jpg', '.png']:
+            jpg_thumbnail_filename = thumbnail_filename + ".jpg"
+
+            self._downloader.to_screen('[ffmpeg] Converting thumbnail "%s" to JPEG' % thumbnail_filename)
+
+            self.run_ffmpeg(thumbnail_filename, jpg_thumbnail_filename, ['-bsf:v', 'mjpeg2jpeg'])
+
+            os.remove(thumbnail_filename)
+            thumbnail_filename = jpg_thumbnail_filename
+
         if info['ext'] == 'mp3':
             options = [
                 '-c', 'copy', '-map', '0', '-map', '1',