Merge 463aa0a4ad1b6241924b1baf7d7be9aee900608a into df129c7ba30aaa9ffffb81a48f53aa7253b0b4e6

This commit is contained in:
Rocky Cai 2022-07-11 16:48:05 -07:00 committed by GitHub
commit acdd32ffb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,7 @@ from ._run import Error
from ._utils import convert_kwargs_to_cmd_line_args
def probe(filename, cmd='ffprobe', timeout=None, **kwargs):
def probe(filename, cmd='ffprobe', input=None, timeout=None, **kwargs):
"""Run ffprobe on the specified file and return a JSON representation of the output.
Raises:
@ -17,11 +17,10 @@ def probe(filename, cmd='ffprobe', timeout=None, **kwargs):
args += convert_kwargs_to_cmd_line_args(kwargs)
args += [filename]
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
communicate_kwargs = {}
if timeout is not None:
communicate_kwargs['timeout'] = timeout
out, err = p.communicate(**communicate_kwargs)
p = subprocess.Popen(
args, stdin=None if input is None else subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate(input=input, timeout=timeout)
if p.returncode != 0:
raise Error('ffprobe', out, err)
return json.loads(out.decode('utf-8'))