new param on probe to get stderr

This commit is contained in:
Ezequiel Ramos 2021-11-03 14:06:00 -03:00
parent f3079726fa
commit 6916ab2768

View File

@ -4,7 +4,7 @@ from ._run import Error
from ._utils import convert_kwargs_to_cmd_line_args from ._utils import convert_kwargs_to_cmd_line_args
def probe(filename, cmd='ffprobe', timeout=None, **kwargs): def probe(filename, cmd='ffprobe', timeout=None, capture_stderr=False, **kwargs):
"""Run ffprobe on the specified file and return a JSON representation of the output. """Run ffprobe on the specified file and return a JSON representation of the output.
Raises: Raises:
@ -24,6 +24,8 @@ def probe(filename, cmd='ffprobe', timeout=None, **kwargs):
out, err = p.communicate(**communicate_kwargs) out, err = p.communicate(**communicate_kwargs)
if p.returncode != 0: if p.returncode != 0:
raise Error('ffprobe', out, err) raise Error('ffprobe', out, err)
if capture_stderr:
return json.loads(out.decode('utf-8')), err
return json.loads(out.decode('utf-8')) return json.loads(out.decode('utf-8'))