harry0703/MoneyPrinterTurbo · error · ElevenLabsMusicError

ElevenLabs supports videos up to 600 seconds

Error message

ElevenLabs supports videos up to 600 seconds

What it means

Duration cap in generate_bgm: the video is longer than MAX_VIDEO_DURATION_SECONDS (600s), the documented ElevenLabs video-to-music limit. Rejected client-side so a multi-hundred-MB upload is not attempted just to receive a 422/413.

Source

Thrown at app/services/elevenlabs_music.py:383

    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"
        )

    proxy_path = ""
    try:
        proxy_path = _create_video_proxy(video_path)
        return _request_bgm(proxy_path, output_path, prompt)
    except ElevenLabsMusicError:
        raise
    except OSError as exc:
        raise ElevenLabsMusicError(
            f"ElevenLabs local file operation failed: {exc}"
        ) from exc

View on GitHub (pinned to 1f9f19c202)

Solutions

  1. Check the duration unit first: a value like 10800 almost always means minutes/milliseconds were passed as seconds
  2. Split the video into <=600s segments and generate/concat audio per segment if long content is required
  3. Trim the video to <=600 seconds if full-length music is not a hard requirement

Example fix

# before
generate_bgm(video, out, total_seconds, prompt)  # total_seconds = 1500

# after
MAX_LEN = 600
segments = split_video(video, MAX_LEN)  # each <= 600s
total_seconds = min(total_seconds, MAX_LEN * len(segments))
audio = generate_bgm(segments[0], out, total_seconds, prompt)  # per-segment strategy
Defensive patterns

Strategy: validation

Validate before calling

from app.services.elevenlabs_music import MAX_VIDEO_DURATION_SECONDS

assert 0 < duration <= MAX_VIDEO_DURATION_SECONDS

Prevention

When it happens

Trigger: Any generate_bgm call where the validated duration exceeds 600 seconds — e.g. long-form compilations, a duration computed in the wrong unit (minutes passed as seconds), or a concat bug joining the same clips repeatedly.

Common situations: Unit mistakes (duration in milliseconds or minutes fed to a seconds parameter), 'loop video N times' features multiplying length past 10 minutes, or legitimately long content that simply exceeds the API plan.

Related errors


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