Spaces:
Sleeping
Sleeping
File size: 520 Bytes
a1aa00b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import json
import subprocess
from pathlib import Path
def ffprobe_json(path: Path) -> dict:
cmd = [
"ffprobe", "-v", "error",
"-print_format", "json",
"-show_format", "-show_streams",
str(path)
]
p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
if p.returncode != 0:
return {"error": p.stderr[-1600:]}
try:
return json.loads(p.stdout)
except Exception:
return {"error": "Failed to parse ffprobe output."} |