{"record":{"id":"1f77ac810dd59eb9","repo":"Panniantong/Agent-Reach","slug":"ffmpeg-produced-no-chunks","errorCode":null,"errorMessage":"ffmpeg produced no chunks","messagePattern":"ffmpeg produced no chunks","errorType":"exception","errorClass":"TranscribeError","httpStatus":null,"severity":"error","filePath":"agent_reach/transcribe.py","lineNumber":351,"sourceCode":"            str(src),\n            \"-t\",\n            str(MAX_AUDIO_SECONDS),\n            \"-f\",\n            \"segment\",\n            \"-segment_time\",\n            str(segment_seconds),\n            \"-ac\",\n            \"1\",\n            \"-ar\",\n            \"16000\",\n            \"-b:a\",\n            \"32k\",\n            str(pattern),\n        ]\n    )\n    chunks = sorted(out_dir.glob(\"chunk_*.m4a\"))\n    if not chunks:\n        raise TranscribeError(\"ffmpeg produced no chunks\")\n    return chunks\n\n\ndef _provider_key(provider: str, config: Config) -> Optional[str]:\n    field = PROVIDERS[provider][\"key_field\"]\n    val = config.get(field)\n    return val or None\n\n\ndef transcribe_chunk(\n    chunk: Path,\n    provider: str,\n    *,\n    config: Optional[Config] = None,\n    timeout: int = 120,\n) -> str:\n    \"\"\"Transcribe one chunk via the named provider. Raises TranscribeError on failure.\"\"\"\n    if provider not in PROVIDERS:","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/Panniantong/Agent-Reach/blob/93ae1d18c37b707dec053c7c4f9d91cd8ef8943d/agent_reach/transcribe.py#L333-L369","documentation":"Raised by chunk_audio (transcribe.py:349-351) when ffmpeg's segment command exits 0 (or at least ran) but no chunk_*.m4a files match the out_dir glob. The pipeline expects at least one segment for any valid input, so zero chunks means the input had no usable audio stream or was empty.","triggerScenarios":"Feeding compress_audio output that is zero-length (upstream media with audio track but no samples), a corrupt m4a that ffmpeg reads as 0s, or an input whose audio stream failed to decode while -loglevel error suppressed warnings. Note ffmpeg itself already caps output with -t 14400, so overlong input truncates rather than yielding nothing.","commonSituations":"Silent/black videos where yt-dlp still produced a file; partially downloaded files after a retried transfer; unusual codecs where the aac encoder gets no frames. Usually preceded by a compress_audio step that produced a tiny or 0-byte compressed.m4a.","solutions":["Inspect the input: ffprobe -show_streams compressed.m4a — check duration and that an audio stream exists","Check file sizes in out_dir: a ~0-byte compressed.m4a points upstream (bad source media); re-download or pick another source","Test the ffmpeg segment command manually with -loglevel warning to surface decode errors"],"exampleFix":"# before\nchunks = chunk_audio(compressed, out_dir)  # ffmpeg produced no chunks\n\n# after: guard on stream viability first\nimport subprocess, json\ninfo = subprocess.run([\"ffprobe\", \"-v\", \"error\", \"-show_streams\", \"-select_streams\", \"a\", \"-of\", \"json\", str(compressed)], capture_output=True, text=True)\nstreams = json.loads(info.stdout).get(\"streams\", [])\nif not streams or float(streams[0].get(\"duration\", 0)) <= 0:\n    raise ValueError(\"source has no decodable audio\")\nchunks = chunk_audio(compressed, out_dir)","handlingStrategy":"validation","validationCode":"import subprocess, json\nfrom pathlib import Path\n\ndef has_decodable_audio(path: Path) -> bool:\n    out = subprocess.run(\n        [\"ffprobe\", \"-v\", \"error\", \"-select_streams\", \"a\", \"-show_streams\",\n         \"-of\", \"json\", str(path)],\n        capture_output=True, text=True,\n    )\n    if out.returncode != 0:\n        return False\n    streams = json.loads(out.stdout).get(\"streams\", [])\n    return bool(streams) and float(streams[0].get(\"duration\") or 0) > 0","typeGuard":null,"tryCatchPattern":"from agent_reach.transcribe import TranscribeError\ntry:\n    chunks = chunk_audio(compressed, out_dir)\nexcept TranscribeError as e:\n    if \"produced no chunks\" in str(e):\n        raise ValueError(\"source media has no decodable audio stream\") from None\n    raise","preventionTips":["ffprobe for an audio stream with positive duration before chunking","Reject ~0-byte compressed outputs right after compress_audio","Prefer well-formed media sources; re-download partial transfers"],"tags":["ffmpeg","chunking","media","transcription"],"backgroundTag":null,"analyzedSha":"93ae1d18c37b707dec053c7c4f9d91cd8ef8943d","analyzedAt":"2026-08-14T22:54:06.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}