Unverified Commit 463aa0a4 authored by Rocky Cai's avatar Rocky Cai Committed by GitHub
Browse files

Support pipe input in ffprobe

Usage: `ffmpeg.probe('pipe:', input=video_bytes)`. The API is similar to `fmpeg.run()`.
https://github.com/kkroening/ffmpeg-python/tree/master/examples#tensorflow-streaming

This is helpful when we want to probe the video bytes in a database.
parent f3079726
Pipeline #1451 failed with stages
Showing with 5 additions and 6 deletions
+5 -6
......@@ -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'))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment