{"record":{"id":"ffbb6d7ba750e8a5","repo":"harry0703/MoneyPrinterTurbo","slug":"failed-to-run-ffmpeg-for-elevenlabs-video-proxy","errorCode":null,"errorMessage":"failed to run FFmpeg for ElevenLabs video proxy","messagePattern":"failed to run FFmpeg for ElevenLabs video proxy","errorType":"exception","errorClass":"ElevenLabsMusicError","httpStatus":null,"severity":"error","filePath":"app/services/elevenlabs_music.py","lineNumber":250,"sourceCode":"        str(MAX_PROXY_BYTES),\n        proxy_path,\n    ]\n    try:\n        result = subprocess.run(\n            command,\n            capture_output=True,\n            text=True,\n            timeout=600,\n            check=False,\n        )\n    except subprocess.TimeoutExpired as exc:\n        _remove_file(proxy_path)\n        raise ElevenLabsMusicError(\n            \"ElevenLabs video proxy generation timed out\"\n        ) from exc\n    except OSError as exc:\n        _remove_file(proxy_path)\n        raise ElevenLabsMusicError(\n            \"failed to run FFmpeg for ElevenLabs video proxy\"\n        ) from exc\n    if result.returncode != 0:\n        _remove_file(proxy_path)\n        detail = (result.stderr or \"\").strip().replace(\"\\n\", \" \")[-500:]\n        raise ElevenLabsMusicError(\n            f\"failed to generate ElevenLabs video proxy: {detail}\"\n        )\n    proxy_size = os.path.getsize(proxy_path) if os.path.isfile(proxy_path) else 0\n    if proxy_size <= 0 or proxy_size > MAX_PROXY_BYTES:\n        _remove_file(proxy_path)\n        raise ElevenLabsMusicError(\n            \"ElevenLabs video proxy is empty or exceeds the 200 MB limit\"\n        )\n    logger.info(\n        \"ElevenLabs video proxy prepared: \"\n        f\"source={video_path}, size={proxy_size} bytes\"\n    )","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/app/services/elevenlabs_music.py#L232-L268","documentation":"ElevenLabsMusicError raised when subprocess.run cannot even launch or manage the FFmpeg process — OSError (e.g. FileNotFoundError when the ffmpeg binary is missing from PATH, or PermissionError). The half-written proxy file is removed and the original OS error is chained. This is an environment problem, not a video problem: FFmpeg was never successfully executed.","triggerScenarios":"ffmpeg (or the configured FFmpeg executable) is not installed or not on PATH in the running process's environment; the binary lacks execute permission; resource limits (fork failure) on constrained containers.","commonSituations":"Slim Docker images without the ffmpeg package; virtualenvs/IDE launches that scrub PATH; images where ffmpeg was copied without +x; cgroup pids/memory limits causing process spawn failure.","solutions":["Install FFmpeg in the runtime environment (apt-get install ffmpeg / apk add ffmpeg) and verify `ffmpeg -version` runs as the same user.","If launching from an IDE/service manager, ensure PATH includes the FFmpeg location or use an absolute binary path configuration.","Check execute permissions on the binary in custom images."],"exampleFix":"# Dockerfile fix\n# before: FROM python:3.12-slim\n# after\nFROM python:3.12-slim\nRUN apt-get update && apt-get install -y --no-install-recommends ffmpeg && rm -rf /var/lib/apt/lists/*","handlingStrategy":"validation","validationCode":"import shutil, subprocess\n\ndef ffmpeg_ready() -> bool:\n    path = shutil.which('ffmpeg')\n    if not path:\n        return False\n    return subprocess.run([path, '-version'], capture_output=True).returncode == 0","typeGuard":null,"tryCatchPattern":"try:\n    generate_bgm(video_path, output_path, prompt)\nexcept ElevenLabsMusicError as e:\n    if 'failed to run FFmpeg' in str(e):\n        raise EnvironmentError('FFmpeg not runnable; install it and retry') from e","preventionTips":["Include ffmpeg in the deployment image and verify `ffmpeg -version` as the app user in CI.","Use absolute FFmpeg paths or ensure PATH is inherited by the service.","Fail fast at startup with an FFmpeg readiness check instead of mid-generation."],"tags":["elevenlabs","ffmpeg","environment","dependency-missing"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}