Panniantong/Agent-Reach · error · TranscribeError

ffprobe timed out while reading audio duration after {FFPROB

Error message

ffprobe timed out while reading audio duration after {FFPROBE_TIMEOUT_SECONDS}s

What it means

Raised by _probe_audio_duration() in agent_reach/transcribe.py when the ffprobe subprocess exceeds FFPROBE_TIMEOUT_SECONDS (30 s) and subprocess.run raises TimeoutExpired. Bounding the probe prevents a hung ffprobe (e.g. on a pathological or corrupt file) from blocking the pipeline forever. from None suppresses the TimeoutExpired traceback for a cleaner error.

Source

Thrown at agent_reach/transcribe.py:115

        "-v",
        "error",
        "-show_entries",
        "format=duration",
        "-of",
        "default=noprint_wrappers=1:nokey=1",
        "-i",
        str(path),
    ]
    try:
        proc = subprocess.run(
            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):

View on GitHub (pinned to 93ae1d18c3)

Solutions

  1. Copy the media to local disk before transcribing
  2. Re-mux the file to repair container corruption: ffmpeg -i in.mp4 -c copy fixed.mp4
  3. If genuinely slow media is expected, raise FFPROBE_TIMEOUT_SECONDS in your environment/config if the module exposes it, otherwise pre-validate duration yourself with a longer timeout

Example fix

# before: ffprobe hangs >30s on network mount
transcribe_audio(Path('/mnt/nas/talk.mp3'))

# after: stage locally first
import shutil; shutil.copy('/mnt/nas/talk.mp3', '/tmp/talk.mp3')
transcribe_audio(Path('/tmp/talk.mp3'))
Defensive patterns

Strategy: retry

Validate before calling

import subprocess
try:
    subprocess.run(['ffprobe', '-v', 'error', '-show_entries', 'format=duration', '-i', str(path)], capture_output=True, timeout=60)
except subprocess.TimeoutExpired:
    raise ValueError('media not probeable in reasonable time; copy locally or repair')

Try / catch

from agent_reach.transcribe import TranscribeError
try:
    transcribe_audio(path)
except TranscribeError as e:
    if 'timed out' in str(e):
        local = stage_to_tmp(path); transcribe_audio(local)  # one retry on local disk
    else:
        raise

Prevention

When it happens

Trigger: Running ffprobe against a slow network mount, a named pipe, a corrupt/infinite container, or an overloaded CPU where reading format metadata takes over 30 s.

Common situations: Media on NFS/SMB shares with high latency; a truncated download that ffprobe scans endlessly; CI runners under heavy load.

Understand the failure class

Related errors


AI-assisted analysis of Panniantong/Agent-Reach@93ae1d18c3 (2026-08-14). Data as JSON: /api/errors/17f3f8cc21e04a13. Report an issue: GitHub.