{"record":{"id":"415202f07eeaa623","repo":"harry0703/MoneyPrinterTurbo","slug":"failed-to-generate-elevenlabs-video-proxy-detail","errorCode":null,"errorMessage":"failed to generate ElevenLabs video proxy: {detail}","messagePattern":"failed to generate ElevenLabs video proxy: (.+?)","errorType":"exception","errorClass":"ElevenLabsMusicError","httpStatus":null,"severity":"error","filePath":"app/services/elevenlabs_music.py","lineNumber":256,"sourceCode":"            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    )\n    return proxy_path\n\n\ndef _stream_audio(response: requests.Response, temp_audio_path: str) -> int:\n    \"\"\"分块保存音频并限制最大体积，防止异常响应耗尽本机磁盘。\"\"\"\n    total_bytes = 0","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/app/services/elevenlabs_music.py#L238-L274","documentation":"ElevenLabsMusicError raised after FFmpeg exits with a non-zero return code while building the video proxy. The message embeds the last 500 characters of stderr with newlines flattened, which is the authoritative reason: usually a corrupt/unsupported input, missing codec, or invalid filter options. The partial proxy file is removed before raising.","triggerScenarios":"Feeding a corrupted, truncated, or DRM-protected video; a codec/container the local FFmpeg build cannot decode (e.g. HEVC without libde265, or an .avi with an exotic codec); or a source that disappeared mid-run. Read the embedded stderr tail to identify which.","commonSituations":"Half-downloaded or remuxed files; distro FFmpeg builds without common codecs; HEVC/AV1 content hitting a minimal build; concurrent cleanup deleting the input while the job runs.","solutions":["Read the stderr fragment in the message — it names the exact FFmpeg failure (e.g. 'Unknown encoder', 'Invalid data found').","Verify the input plays locally (ffprobe video.mp4) and re-encode it once to a safe profile (H.264/AAC in MP4) before retrying.","If the error names a missing encoder/decoder, install a full FFmpeg build."],"exampleFix":"# normalize problematic input before submitting\nffmpeg -i input.mov -c:v libx264 -c:a aac -movflags +faststart normalized.mp4","handlingStrategy":"validation","validationCode":"import subprocess\n\ndef video_decodes(path: str) -> bool:\n    return subprocess.run(\n        ['ffprobe', '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'stream=codec_name', '-of', 'csv=p=0', path],\n        capture_output=True,\n    ).returncode == 0","typeGuard":null,"tryCatchPattern":"try:\n    generate_bgm(video_path, output_path, prompt)\nexcept ElevenLabsMusicError as e:\n    if 'failed to generate ElevenLabs video proxy' in str(e):\n        log(e)  # stderr tail is embedded — it names the codec/filter failure\n        reencode_to_h264(video_path); retry_once()","preventionTips":["Validate inputs with ffprobe before submitting to the music flow.","Normalize exotic codecs/containers to H.264/AAC MP4 upstream.","Read the embedded 500-char stderr tail — it pinpoints the exact FFmpeg fault."],"tags":["elevenlabs","ffmpeg","video-encoding","corrupt-input"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}