1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2026-02-11 16:34:25 +00:00

[ffmpeg] Allow passing custom arguments before -i

:ci skip dl
This commit is contained in:
pukkandan
2021-02-24 21:35:18 +05:30
parent e409895f13
commit 5b1ecbb327
7 changed files with 42 additions and 34 deletions

View File

@@ -91,11 +91,10 @@ class PostProcessor(object):
except Exception:
self.report_warning(errnote)
def _configuration_args(self, default=[], exe=None):
key = self.pp_key().lower()
args, is_compat = cli_configuration_args(
self._downloader.params, 'postprocessor_args', key, default, exe)
return args if not is_compat or key != 'sponskrub' else default
def _configuration_args(self, *args, **kwargs):
return cli_configuration_args(
self._downloader.params.get('postprocessor_args'),
self.pp_key().lower(), *args, **kwargs)
class AudioConversionError(PostProcessingError):

View File

@@ -239,21 +239,20 @@ class FFmpegPostProcessor(PostProcessor):
oldest_mtime = min(
os.stat(encodeFilename(path)).st_mtime for path in input_paths)
opts += self._configuration_args(exe=self.basename)
files_cmd = []
for path in input_paths:
files_cmd.extend([
encodeArgument('-i'),
encodeFilename(self._ffmpeg_filename_argument(path), True)
])
cmd = [encodeFilename(self.executable, True), encodeArgument('-y')]
# avconv does not have repeat option
if self.basename == 'ffmpeg':
cmd += [encodeArgument('-loglevel'), encodeArgument('repeat+info')]
cmd += (files_cmd
+ [encodeArgument(o) for o in opts]
+ [encodeFilename(self._ffmpeg_filename_argument(out_path), True)])
def make_args(file, pre=[], post=[], *args, **kwargs):
args = pre + self._configuration_args(*args, **kwargs) + post
return (
[encodeArgument(o) for o in args]
+ [encodeFilename(self._ffmpeg_filename_argument(file), True)])
for i, path in enumerate(input_paths):
cmd += make_args(path, post=['-i'], exe='%s_i%d' % (self.basename, i+1), use_default_arg=False)
cmd += make_args(out_path, pre=opts, exe=self.basename)
self.write_debug('ffmpeg command line: %s' % shell_quote(cmd))
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)

View File

@@ -71,7 +71,7 @@ class SponSkrubPP(PostProcessor):
if not self.cutout:
cmd += ['-chapter']
cmd += compat_shlex_split(self.args) # For backward compatibility
cmd += self._configuration_args(exe=self._exe_name)
cmd += self._configuration_args(exe=self._exe_name, use_default_arg='no_compat')
cmd += ['--', information['id'], filename, temp_filename]
cmd = [encodeArgument(i) for i in cmd]