]> jfr.im git - yt-dlp.git/commitdiff
Merge webm formats into mkv if thumbnails are to be embedded
authorpukkandan <redacted>
Sat, 9 Oct 2021 16:18:46 +0000 (21:48 +0530)
committerpukkandan <redacted>
Sat, 9 Oct 2021 16:49:23 +0000 (22:19 +0530)
This was originally implemented in 4d971a16b831a45147b6ae7ce53b3e105d204da7 (#173) by @damianoamatruda
but was reverted in 3b297919e046082cc4ab26ecb959d9f4f584102b
since it was unintentionally being triggered for `write_thumbnail` (See #500)

yt_dlp/YoutubeDL.py

index 1d865161af31685c00a957a6a4bb880c0ad7d518..398fb67af17e7517cf694b101e031bcdb340c315 100644 (file)
 from .downloader.rtmp import rtmpdump_version
 from .postprocessor import (
     get_postprocessor,
+    EmbedThumbnailPP,
     FFmpegFixupDurationPP,
     FFmpegFixupM3u8PP,
     FFmpegFixupM4aPP,
@@ -2696,10 +2697,19 @@ def compatible_formats(formats):
 
                     requested_formats = info_dict['requested_formats']
                     old_ext = info_dict['ext']
-                    if self.params.get('merge_output_format') is None and not compatible_formats(requested_formats):
-                        info_dict['ext'] = 'mkv'
-                        self.report_warning(
-                            'Requested formats are incompatible for merge and will be merged into mkv.')
+                    if self.params.get('merge_output_format') is None:
+                        if not compatible_formats(requested_formats):
+                            info_dict['ext'] = 'mkv'
+                            self.report_warning(
+                                'Requested formats are incompatible for merge and will be merged into mkv')
+                        if (info_dict['ext'] == 'webm'
+                                and info_dict.get('thumbnails')
+                                # check with type instead of pp_key, __name__, or isinstance
+                                # since we dont want any custom PPs to trigger this
+                                and any(type(pp) == EmbedThumbnailPP for pp in self._pps['post_process'])):
+                            info_dict['ext'] = 'mkv'
+                            self.report_warning(
+                                'webm doesn\'t support embedding a thumbnail, mkv will be used')
                     new_ext = info_dict['ext']
 
                     def correct_ext(filename, ext=new_ext):