]> jfr.im git - yt-dlp.git/commitdiff
[embedthumbnail] Fix `_get_thumbnail_resolution`
authorpukkandan <redacted>
Sat, 10 Jul 2021 22:37:25 +0000 (04:07 +0530)
committerpukkandan <redacted>
Sat, 10 Jul 2021 23:16:53 +0000 (04:46 +0530)
yt_dlp/postprocessor/embedthumbnail.py
yt_dlp/postprocessor/ffmpeg.py

index 48d4b673d8052e55f78c599f51d31dc10d729771..7008f4d4dbfb5d155b795df8f956979d9d474b6c 100644 (file)
@@ -51,7 +51,7 @@ def guess():
 
         try:
             size_regex = r',\s*(?P<w>\d+)x(?P<h>\d+)\s*[,\[]'
-            size_result = self.run_ffmpeg(filename, filename, ['-hide_banner'])
+            size_result = self.run_ffmpeg(filename, None, ['-hide_banner'], expected_retcodes=(1,))
             mobj = re.search(size_regex, size_result)
             if mobj is None:
                 return guess()
index 85cd0288a0492f539d3a4c7cf6b31b0c397919ab..eb5ae17371daa81de4851a32eba1c37d46aa112e 100644 (file)
@@ -235,12 +235,12 @@ def get_stream_number(self, path, keys, value):
             None)
         return num, len(streams)
 
-    def run_ffmpeg_multiple_files(self, input_paths, out_path, opts):
+    def run_ffmpeg_multiple_files(self, input_paths, out_path, opts, **kwargs):
         return self.real_run_ffmpeg(
             [(path, []) for path in input_paths],
-            [(out_path, opts)])
+            [(out_path, opts)], **kwargs)
 
-    def real_run_ffmpeg(self, input_path_opts, output_path_opts):
+    def real_run_ffmpeg(self, input_path_opts, output_path_opts, *, expected_retcodes=(0,)):
         self.check_version()
 
         oldest_mtime = min(
@@ -270,7 +270,7 @@ def make_args(file, args, name, number):
         self.write_debug('ffmpeg command line: %s' % shell_quote(cmd))
         p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
         stdout, stderr = process_communicate_or_kill(p)
-        if p.returncode != 0:
+        if p.returncode not in variadic(expected_retcodes):
             stderr = stderr.decode('utf-8', 'replace').strip()
             if self.get_param('verbose', False):
                 self.report_error(stderr)
@@ -280,8 +280,8 @@ def make_args(file, args, name, number):
                 self.try_utime(out_path, oldest_mtime, oldest_mtime)
         return stderr.decode('utf-8', 'replace')
 
-    def run_ffmpeg(self, path, out_path, opts):
-        return self.run_ffmpeg_multiple_files([path], out_path, opts)
+    def run_ffmpeg(self, path, out_path, opts, **kwargs):
+        return self.run_ffmpeg_multiple_files([path], out_path, opts, **kwargs)
 
     def _ffmpeg_filename_argument(self, fn):
         # Always use 'file:' because the filename may contain ':' (ffmpeg