8000 Add optional timeout argument to probe · Powercoder64/ffmpeg-python@82a00e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 82a00e4

Browse files
committed
Add optional timeout argument to probe
Popen.communicate() supports a timeout argument which is useful in case there is a risk that the probe hangs.
1 parent 78fb6cf commit 82a00e4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ffmpeg/_probe.py

Lines changed: 2 additions & 2 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', **kwargs):
7+
def probe(filename, cmd='ffprobe', timeout=None, **kwargs):
88
"""Run ffprobe on the specified file and return a JSON representation of the output.
99
1010
Raises:
@@ -18,7 +18,7 @@ def probe(filename, cmd='ffprobe', **kwargs):
1818
args += [filename]
1919

2020
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
21-
out, err = p.communicate()
21+
out, err = p.communicate(timeout=timeout)
2222
if p.returncode != 0:
2323
raise Error('ffprobe', out, err)
2424
return json.loads(out.decode('utf-8'))

0 commit comments

Comments
 (0)
0