harry0703/MoneyPrinterTurbo · error · ElevenLabsMusicError

ElevenLabs input video does not exist

Error message

ElevenLabs input video does not exist

What it means

Guard in generate_bgm: os.path.isfile(video_path) is false — the input video file does not exist (or is a directory). Checked before any network or proxy work so the task fails fast instead of uploading garbage or crashing later in _create_video_proxy.

Source

Thrown at app/services/elevenlabs_music.py:373

            "ElevenLabs background music generated: "
            f"output={output_path}, size={total_bytes} bytes"
        )
        return output_path
    finally:
        _remove_file(temp_audio_path)


def generate_bgm(
    video_path: str,
    output_path: str,
    video_duration: float,
    prompt: str = "",
) -> str:
    """为一条已拼接视频生成时长和画面匹配的 ElevenLabs 背景音乐。"""
    if not get_api_key():
        raise ElevenLabsMusicError("ElevenLabs API key is required")
    if not os.path.isfile(video_path):
        raise ElevenLabsMusicError("ElevenLabs input video does not exist")
    try:
        duration = float(video_duration)
    except (TypeError, ValueError) as exc:
        raise ElevenLabsMusicError(
            "ElevenLabs video duration is invalid"
        ) from exc
    if not math.isfinite(duration) or duration <= 0:
        raise ElevenLabsMusicError("ElevenLabs video duration is invalid")
    if duration > MAX_VIDEO_DURATION_SECONDS:
        raise ElevenLabsMusicError(
            "ElevenLabs supports videos up to 600 seconds"
        )
    prompt = str(prompt or "").strip()
    if len(prompt) > MAX_PROMPT_LENGTH:
        raise ElevenLabsMusicError(
            "ElevenLabs music prompt exceeds 1000 characters"
        )

View on GitHub (pinned to 1f9f19c202)

Solutions

  1. Verify the concat/render step actually produced the file and that the path passed to generate_bgm is the same absolute path
  2. Use absolute paths (Path(video_path).resolve()) when queueing the BGM job
  3. Check mount points if generation and BGM run in different containers
  4. Add an existence assertion right after the render step to catch deletion races early

Example fix

# before
generate_bgm(video_path, output_path, duration, prompt)  # path may be stale

# after
video_path = str(Path(video_path).resolve())
if not os.path.isfile(video_path):
    raise FileNotFoundError(f"concatenated video missing before BGM: {video_path}")
generate_bgm(video_path, output_path, duration, prompt)
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

p = Path(video_path).resolve()
assert p.is_file(), f"missing input video: {p}"

Prevention

When it happens

Trigger: Calling generate_bgm with a path that was never rendered, was already deleted by a cleanup step, lives on an unmounted volume, or points at a directory.

Common situations: Race between a temp-file cleanup and the BGM step in the pipeline, passing a relative path while the process cwd changed, video rendered in a container path not mounted into the worker, or a typo'd path from task config.

Related errors


AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14). Data as JSON: /api/errors/63dfafa997ffe073. Report an issue: GitHub.