Probe duration via demux fallback (webm N/A); run one flow at a time, queue the rest
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""SQLite index of meetings (out/meetings.db) + shared helpers."""
|
||||
import json, re, sqlite3, time
|
||||
import json, re, sqlite3, subprocess, time
|
||||
from pathlib import Path
|
||||
|
||||
HERE = Path(__file__).parent
|
||||
@@ -177,6 +177,20 @@ def media(name):
|
||||
return first(".webm", ".wav", ".mp4", ".mkv", ".mov", ".m4a", ".mp3"), first(".webm", ".mp4", ".mkv", ".mov")
|
||||
|
||||
|
||||
def duration(path) -> float:
|
||||
"""Seconds. MediaRecorder webm has no container duration (N/A): fall back to a copy-demux pass (~1 s/h)."""
|
||||
p = subprocess.run(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", str(path)],
|
||||
capture_output=True, text=True)
|
||||
try: return float(p.stdout.strip())
|
||||
except ValueError: pass
|
||||
r = subprocess.run(["ffmpeg", "-v", "error", "-stats", "-i", str(path), "-map", "0", "-c", "copy", "-f", "null", "-"],
|
||||
capture_output=True, text=True)
|
||||
m = re.findall(r"time=(\d+):(\d\d):(\d\d(?:\.\d+)?)", r.stderr)
|
||||
if not m: raise ValueError(((p.stderr or r.stderr).strip() or "nessuna durata")[-300:])
|
||||
h, mi, s = m[-1]
|
||||
return int(h) * 3600 + int(mi) * 60 + float(s)
|
||||
|
||||
|
||||
def add_events(name, rows):
|
||||
connect().executemany("INSERT INTO call_events(name,t,kind,who_key,who,text) VALUES(?,?,?,?,?,?)",
|
||||
[(name, *r) for r in rows])
|
||||
|
||||
Reference in New Issue
Block a user