VT-PR/vinetrimmer/utils/subprocess.py
Aswin f8c4accd54 Reset
Reset dev
2025-03-18 00:17:27 +05:30

30 lines
762 B
Python

import json
import subprocess
def ffprobe(uri):
"""Use ffprobe on the provided data to get stream information."""
args = [
"ffprobe",
"-v", "quiet",
"-of", "json",
"-show_streams"
]
if isinstance(uri, str):
args.extend([
"-f", "lavfi",
"-i", "movie={}[out+subcc]".format(uri.replace("\\", '/').replace(":", "\\\\:"))
])
elif isinstance(uri, bytes):
args.append("pipe:")
try:
ff = subprocess.run(
args,
input=uri if isinstance(uri, bytes) else None,
check=True,
capture_output=True
)
except subprocess.CalledProcessError:
return {}
return json.loads(ff.stdout.decode("utf-8"))