{"record":{"id":"a085c1388fcb6f03","repo":"affaan-m/ECC","slug":"ffmpeg-failed-join-cmd-6-proc-stderr-400","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-application/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-application/scripts/taste/assemble.py#L13-L49","documentation":"This RuntimeError is raised by the internal _run() helper in assemble.py whenever an ffmpeg subprocess exits with a non-zero return code. The message includes the first six argv tokens (to identify the operation: cut_take, overlay, concat, or normalize) and the last 400 characters of ffmpeg's stderr for diagnosis. It is a generic wrapper: the real cause is always in the captured stderr.","triggerScenarios":"Any call to cut_take(), overlay(), concat(), or normalize() where the constructed ffmpeg command fails — e.g. invalid filter graph syntax, missing input file, unsupported codec/parameters, or a malformed output path — since _run() propagates every subprocess failure as this RuntimeError.","commonSituations":"Building a filter_complex string with an invalid pad/scale expression; pointing cut_take at a source ffmpeg cannot decode; requesting an output format/extension ffmpeg doesn't recognize; a broken ffmpeg installation or wrong binary on PATH producing option errors.","solutions":["Read the stderr tail in the message (after the '...') — it contains ffmpeg's actual error; fix the option/filter it complains about","Run the exact ffmpeg command shown in the message manually with full arguments to reproduce and iterate on the failure","Verify the input file exists and is decodable: ffprobe <input>","Check the output path/extension maps to a supported muxer/codec","Confirm ffmpeg is installed and on PATH (ffmpeg -version) and matches expected version behavior"],"exampleFix":"# before\n_run([\"ffmpeg\", \"-i\", src, \"-vf\", \"pad=-10:-10\", out])  # negative pad kills filtergraph\n# after\n_run([\"ffmpeg\", \"-i\", src, \"-vf\", f\"pad={width}:{height}:0:0\", out])  # valid non-negative offsets","handlingStrategy":"try-catch","validationCode":"import shutil\nassert shutil.which(\"ffmpeg\"), \"ffmpeg not on PATH\"\nimport subprocess\nprobe = subprocess.run([\"ffprobe\", \"-v\", \"error\", str(src)], capture_output=True, text=True)\nassert probe.returncode == 0, f\"undecodable input: {probe.stderr}\"","typeGuard":null,"tryCatchPattern":"try:\n    cut_take(src, shots, dest)\nexcept RuntimeError as e:\n    msg = str(e)\n    stderr_tail = msg.split(\"...\", 1)[-1]\n    print(f\"ffmpeg failed:\\n{stderr_tail}\")  # inspect and fix the offending command\n    raise","preventionTips":["ffprobe every input before assembling","Keep filtergraph strings simple and test pad/scale expressions with a single frame first","Pin and verify the ffmpeg version in your environment","Log the full command (not just the first 6 tokens) for debugging"],"tags":["ffmpeg","subprocess","video-processing","runtime-error"],"backgroundTag":"command-not-found","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"}