[embedthumbnail] Fix `_get_thumbnail_resolution`

This commit is contained in:
pukkandan 2021-07-11 04:07:25 +05:30
parent 325ebc1703
commit 00034c146a
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698
2 changed files with 7 additions and 7 deletions

View File

@ -51,7 +51,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
try: try:
size_regex = r',\s*(?P<w>\d+)x(?P<h>\d+)\s*[,\[]' 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) mobj = re.search(size_regex, size_result)
if mobj is None: if mobj is None:
return guess() return guess()

View File

@ -235,12 +235,12 @@ class FFmpegPostProcessor(PostProcessor):
None) None)
return num, len(streams) 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( return self.real_run_ffmpeg(
[(path, []) for path in input_paths], [(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() self.check_version()
oldest_mtime = min( oldest_mtime = min(
@ -270,7 +270,7 @@ class FFmpegPostProcessor(PostProcessor):
self.write_debug('ffmpeg command line: %s' % shell_quote(cmd)) self.write_debug('ffmpeg command line: %s' % shell_quote(cmd))
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
stdout, stderr = process_communicate_or_kill(p) 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() stderr = stderr.decode('utf-8', 'replace').strip()
if self.get_param('verbose', False): if self.get_param('verbose', False):
self.report_error(stderr) self.report_error(stderr)
@ -280,8 +280,8 @@ class FFmpegPostProcessor(PostProcessor):
self.try_utime(out_path, oldest_mtime, oldest_mtime) self.try_utime(out_path, oldest_mtime, oldest_mtime)
return stderr.decode('utf-8', 'replace') return stderr.decode('utf-8', 'replace')
def run_ffmpeg(self, path, out_path, opts): def run_ffmpeg(self, path, out_path, opts, **kwargs):
return self.run_ffmpeg_multiple_files([path], out_path, opts) return self.run_ffmpeg_multiple_files([path], out_path, opts, **kwargs)
def _ffmpeg_filename_argument(self, fn): def _ffmpeg_filename_argument(self, fn):
# Always use 'file:' because the filename may contain ':' (ffmpeg # Always use 'file:' because the filename may contain ':' (ffmpeg