Skip to content

Commit 1a49eeb

Browse files
authored
Merge pull request #1 from misaka-10032/patch-1
Support pipe input in ffprobe
2 parents df129c7 + 463aa0a commit 1a49eeb

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

ffmpeg/_probe.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ._utils import convert_kwargs_to_cmd_line_args
55

66

7-
def probe(filename, cmd='ffprobe', timeout=None, **kwargs):
7+
def probe(filename, cmd='ffprobe', input=None, timeout=None, **kwargs):
88
"""Run ffprobe on the specified file and return a JSON representation of the output.
99
1010
Raises:
@@ -17,11 +17,10 @@ def probe(filename, cmd='ffprobe', timeout=None, **kwargs):
1717
args += convert_kwargs_to_cmd_line_args(kwargs)
1818
args += [filename]
1919

20-
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
21-
communicate_kwargs = {}
22-
if timeout is not None:
23-
communicate_kwargs['timeout'] = timeout
24-
out, err = p.communicate(**communicate_kwargs)
20+
p = subprocess.Popen(
21+
args, stdin=None if input is None else subprocess.PIPE,
22+
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
23+
out, err = p.communicate(input=input, timeout=timeout)
2524
if p.returncode != 0:
2625
raise Error('ffprobe', out, err)
2726
return json.loads(out.decode('utf-8'))

0 commit comments

Comments
 (0)