{"record":{"id":"5857122f237e2f9b","repo":"harry0703/MoneyPrinterTurbo","slug":"elevenlabs-video-proxy-generation-timed-out","errorCode":null,"errorMessage":"ElevenLabs video proxy generation timed out","messagePattern":"ElevenLabs video proxy generation timed out","errorType":"exception","errorClass":"ElevenLabsMusicError","httpStatus":null,"severity":"error","filePath":"app/services/elevenlabs_music.py","lineNumber":245,"sourceCode":"        \"-pix_fmt\",\n        \"yuv420p\",\n        \"-movflags\",\n        \"+faststart\",\n        \"-fs\",\n        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\"","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/app/services/elevenlabs_music.py#L227-L263","documentation":"ElevenLabsMusicError raised when the FFmpeg subprocess that builds the downscaled video proxy exceeds its hard 600-second timeout: subprocess.run raises TimeoutExpired, the partially written proxy file is removed, and the error is chained. The proxy step exists because ElevenLabs Video-to-Music has duration (max 600s) and size (MAX_PROXY_BYTES = 200 MB) limits, so long/high-bitrate sources need re-encoding first.","triggerScenarios":"Feeding a long or high-resolution video into the ElevenLabs BGM flow on a slow machine: re-encoding to the proxy profile takes more than 600s. CPU-starved containers, software-only FFmpeg, or 4K sources are typical.","commonSituations":"Docker containers limited to a fraction of one CPU; CI runners; 4K/60fps source videos; machines where FFmpeg lacks hardware acceleration and falls back to slow software x264.","solutions":["Reduce CPU load or give the container more CPU so the proxy encodes within 600s.","Pre-downscale very large sources before submitting (e.g. ffmpeg -vf scale=1280:-2) so the proxy step is fast.","Trim the video to the needed length — proxy cost scales with duration (limit is 600s anyway)."],"exampleFix":"# before: submit 4K source directly\ngenerate_bgm(video_path='input_4k.mov', ...)\n\n# after: pre-downscale\nsubprocess.run(['ffmpeg', '-i', 'input_4k.mov', '-vf', 'scale=1280:-2', '-c:v', 'libx264', 'input_hd.mp4'])\ngenerate_bgm(video_path='input_hd.mp4', ...)","handlingStrategy":"retry","validationCode":"import subprocess\n\ndef ffmpeg_available() -> bool:\n    return subprocess.run(['ffmpeg', '-version'], capture_output=True).returncode == 0","typeGuard":null,"tryCatchPattern":"try:\n    generate_bgm(video_path, output_path, prompt)\nexcept ElevenLabsMusicError as e:\n    if 'timed out' in str(e):\n        pre_downscale(video_path)  # cheaper proxy encode\n        generate_bgm(video_path, output_path, prompt)","preventionTips":["Give the runtime enough CPU (avoid 0.1-CPU container limits) for the 600s proxy encode.","Pre-downscale 4K/long sources before submitting to the music flow.","Keep source videos near the actual needed duration — the 600s cap bounds both proxy cost and API limits."],"tags":["elevenlabs","ffmpeg","timeout","video-encoding"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}