Panniantong/Agent-Reach · error · TranscribeError
ffprobe failed while reading audio duration: {detail}
Error message
ffprobe failed while reading audio duration: {detail} What it means
Raised by _probe_audio_duration() in agent_reach/transcribe.py when ffprobe exits non-zero while reading format duration. The first 300 characters of ffprobe's stderr become the message detail (or 'unknown ffprobe error' if stderr is empty), so the exact container/codec problem is surfaced — e.g. 'Invalid data found when processing input'.
Source
Thrown at agent_reach/transcribe.py:126
cmd,
capture_output=True,
encoding="utf-8",
errors="replace",
timeout=FFPROBE_TIMEOUT_SECONDS,
)
except subprocess.TimeoutExpired:
raise TranscribeError(
"ffprobe timed out while reading audio duration "
f"after {FFPROBE_TIMEOUT_SECONDS}s"
) from None
except OSError as exc:
raise TranscribeError(
f"ffprobe could not read audio duration: {exc}"
) from exc
if proc.returncode != 0:
detail = proc.stderr.strip()[:300] or "unknown ffprobe error"
raise TranscribeError(
f"ffprobe failed while reading audio duration: {detail}"
)
raw_duration = proc.stdout.strip()
try:
duration = float(raw_duration)
except (TypeError, ValueError):
raise TranscribeError(
"ffprobe could not parse a valid audio duration"
) from None
if not math.isfinite(duration) or duration <= 0:
raise TranscribeError(
"ffprobe could not parse a valid positive audio duration"
)
return duration
def _require_duration_within_budget(path: Path) -> float:View on GitHub (pinned to 93ae1d18c3)
Solutions
- Read the stderr detail in the message — it names the real problem
- Verify the file plays locally or re-obtain it from the source
- Repair the container: ffmpeg -errdetect ignore_err -i in.file -c copy fixed.file
Example fix
# before
transcribe_audio(Path('video.mp4')) # really an HTML error page
# after: validate the download first
assert data[:4] != b'<!DO', 'download failed'
transcribe_audio(Path('video.mp4')) Defensive patterns
Strategy: validation
Validate before calling
import subprocess
r = subprocess.run(['ffprobe', '-v', 'error', '-show_entries', 'format=duration', '-i', str(path)], capture_output=True, text=True)
if r.returncode != 0:
raise ValueError(f'media unreadable by ffprobe: {r.stderr[:300]}') Type guard
def probeable_media(path) -> bool:
r = subprocess.run(['ffprobe', '-v', 'error', '-show_entries', 'format=duration', '-i', str(path)], capture_output=True)
return r.returncode == 0 Try / catch
from agent_reach.transcribe import TranscribeError
try:
transcribe_audio(path)
except TranscribeError as e:
if 'ffprobe failed' in str(e):
repaired = remux(path) # ffmpeg -c copy fallback
transcribe_audio(repaired)
else:
raise Prevention
- Validate downloads (content-type, magic bytes) before transcribing
- Read the embedded stderr detail — it identifies the codec/container fault
- Re-mux suspicious files before retry
When it happens
Trigger: Passing a corrupt, truncated, or non-media file (renamed .mp3 with random bytes); unsupported containers; zero-byte files.
Common situations: Interrupted downloads; files that are actually HTML error pages saved with a media extension; DRM-protected media ffprobe cannot parse.
Related errors
- ffprobe could not parse a valid positive audio duration
- ffprobe timed out while reading audio duration after {FFPROB
- ffprobe could not parse a valid audio duration
- limit must be non-negative
- Missing value for {args.key}
AI-assisted analysis of Panniantong/Agent-Reach@93ae1d18c3 (2026-08-14).
Data as JSON: /api/errors/551d49c14dce851b.
Report an issue: GitHub.