{"record":{"id":"ff6255c109e77e34","repo":"affaan-m/ECC","slug":"ffmpeg-failed-join-cmd-6-proc-stderr-400-assemble","errorCode":null,"errorMessage":"ffmpeg failed: {' '.join(cmd[:6])}...\n{proc.stderr[-400:]}","messagePattern":"ffmpeg failed: (.+?)\\.\\.\\.\n(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"skills/taste-distillation/scripts/taste/assemble.py","lineNumber":31,"sourceCode":"  new material into it;\n* **the cut itself**, at the reference's measured cadence rather than at\n  whatever length the generator happened to emit.\n\"\"\"\n\nfrom __future__ import annotations\n\nimport json\nimport subprocess\nfrom pathlib import Path\n\nfrom . import cadence as cad_mod\nfrom . import frames as frame_mod\n\n\ndef _run(cmd: list[str]) -> None:\n    proc = subprocess.run(cmd, capture_output=True, text=True)\n    if proc.returncode != 0:\n        raise RuntimeError(f\"ffmpeg failed: {' '.join(cmd[:6])}...\\n{proc.stderr[-400:]}\")\n\n\ndef cut_take(\n    src: str | Path,\n    shots: list[dict],\n    dest_dir: str | Path,\n    prefix: str = \"shot\",\n    fps: float | None = None,\n) -> list[Path]:\n    \"\"\"Slice one generated take into its planned sub-shots.\n\n    Re-encodes rather than stream-copying. Stream copy can only cut on\n    keyframes, and at a mean shot length of 0.78s that rounds every boundary\n    to the nearest GOP - which is precisely the rhythm this whole pipeline\n    exists to preserve.\n    \"\"\"\n    src, dest_dir = Path(src), Path(dest_dir)\n    dest_dir.mkdir(parents=True, exist_ok=True)","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-distillation/scripts/taste/assemble.py#L13-L49","documentation":"assemble._run() invokes an ffmpeg subprocess with captured output; if ffmpeg exits non-zero it raises RuntimeError including the first six command words and the last 400 chars of stderr. This is the central ffmpeg failure reporter for all assemble operations (cut_take, overlay, concat, normalize).","triggerScenarios":"Any _run-wrapped ffmpeg invocation returns returncode != 0: invalid filtergraph arguments (e.g. overlay pad geometry out of bounds), missing input file, unsupported codec, bad fps/size flags, or ffmpeg binary missing (though that usually raises FileNotFoundError instead).","commonSituations":"Overlay element sized/positioned outside the frame so pad() errors; concat list references missing clips; input videos with mismatched codecs/resolutions; ffmpeg too old for a filter flag used; disk full during encode.","solutions":["Read the embedded ffmpeg stderr tail in the message — it states the exact filter/option failure; correct that argument.","Run the printed command prefix manually with full args and -loglevel verbose to reproduce and see complete stderr.","For overlay errors, validate element geometry fits within width/height before building the filtergraph (see the size-clamping already done in overlay()).","Confirm all input files exist, are readable, and share codec/size where the operation assumes it (concat, normalize).","Update ffmpeg to a recent build if the error mentions an unknown filter or option."],"exampleFix":"// before\n_run([\"ffmpeg\", \"-i\", src, \"-vf\", f\"overlay={x}:{y}\", out])  # x,y may exceed frame\n\n// after\nx = max(0, min(x, width - ew))\ny = max(0, min(y, height - eh))\n_run([\"ffmpeg\", \"-nostdin\", \"-loglevel\", \"error\", \"-y\", \"-i\", src,\n      \"-vf\", f\"overlay={x}:{y}\", out])","handlingStrategy":"try-catch","validationCode":"import shutil\nif shutil.which(\"ffmpeg\") is None:\n    raise SystemExit(\"ffmpeg not found on PATH\")\nfor src in inputs:\n    if not Path(src).exists():\n        raise SystemExit(f\"input missing for ffmpeg: {src}\")","typeGuard":"null","tryCatchPattern":"try:\n    assemble.overlay(video, logo, ...)\nexcept RuntimeError as exc:\n    log.error(\"ffmpeg step failed: %s\", exc)  # stderr tail is embedded\n    raise","preventionTips":["Always read the stderr tail embedded in the message before changing code","Clamp overlay geometry to frame bounds before building filtergraphs","Reproduce failures by running the command manually with -loglevel verbose","Validate input codecs/sizes match where operations assume compatibility","Keep ffmpeg updated to a recent build"],"tags":["ffmpeg","subprocess","video","filtergraph"],"backgroundTag":"command-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}