harry0703/MoneyPrinterTurbo · warning · ValueError

unsupported custom audio type {audio_extension or '<none>'};

Error message

unsupported custom audio type {audio_extension or '<none>'}; allowed extensions: {allowed}

What it means

After resolving the --custom-audio file, the CLI checks its extension against a fixed whitelist (_CUSTOM_AUDIO_EXTENSIONS, the audio set next to the video set containing .avi/.flv etc.). An extension outside the whitelist — including no extension at all, shown as '<none>' — raises ValueError listing the allowed values.

Source

Thrown at cli.py:673

    from app.services import bgm as bgm_service
    from app.utils import utils

    local_material_extensions = {
        *(f".{extension}" for extension in const.FILE_TYPE_VIDEOS),
        *(f".{extension}" for extension in const.FILE_TYPE_IMAGES),
        ".avi",
        ".flv",
    }

    if params.custom_audio_file:
        params.custom_audio_file = _resolve_cli_file(
            params.custom_audio_file,
            description="custom audio",
        )
        audio_extension = os.path.splitext(params.custom_audio_file)[1].lower()
        if audio_extension not in _CUSTOM_AUDIO_EXTENSIONS:
            allowed = ", ".join(sorted(_CUSTOM_AUDIO_EXTENSIONS))
            raise ValueError(
                f"unsupported custom audio type {audio_extension or '<none>'}; "
                f"allowed extensions: {allowed}"
            )

    if params.bgm_type == "custom":
        if not bgm_service.should_use_bgm(params.bgm_type, params.bgm_volume):
            # 0 音量时下游会统一跳过所有 BGM。这里同时清空文件参数,避免
            # CLI 为一个不会被读取的文件执行路径解析、存在性检查或格式
            # 校验。
            params.bgm_file = ""
        elif not params.bgm_file:
            # 缺少文件是否构成错误取决于通用 BGM 开关,不能在 argparse 阶段
            # 无条件拦截,否则 ``custom + 0%`` 会和 WebUI、服务层行为不一致。
            raise ValueError("--bgm-file is required when --bgm-type is custom")
        else:
            try:
                # CLI、WebUI 和任务服务必须共用同一个 BGM 文件边界。这里直接
                # 复用服务层解析,既支持用户上传目录和内置歌曲目录,也

View on GitHub (pinned to 1f9f19c202)

Solutions

  1. Convert the audio to a whitelisted extension first, e.g. ffmpeg -i in.opus out.mp3.
  2. Rename the file to carry its true, whitelisted extension if the content is already a supported format.
  3. As a maintainer, extend _CUSTOM_AUDIO_EXTENSIONS after verifying downstream ffmpeg/moviepy handles the new format.

Example fix

# before
python cli.py --custom-audio bgm.opus

# after
ffmpeg -i bgm.opus bgm.mp3
python cli.py --custom-audio bgm.mp3
Defensive patterns

Strategy: validation

Validate before calling

import os
_ALLOWED = {".mp3", ".wav", ".flac", ".ogg", ".m4a"}  # mirror _CUSTOM_AUDIO_EXTENSIONS from cli.py
ext = os.path.splitext(params.custom_audio_file)[1].lower()
if ext not in _ALLOWED:
    raise ValueError(f"convert {params.custom_audio_file} to one of {sorted(_ALLOWED)}")

Type guard

def is_supported_custom_audio(path: str) -> bool:
    return os.path.splitext(path)[1].lower() in _CUSTOM_AUDIO_EXTENSIONS

Prevention

When it happens

Trigger: Passing --custom-audio track.m4a/.opus/.aac/.ogg when those are not in the whitelist; a file with no dot in its name (extension '<none>'); uppercase handled only if .lower() of it is in the set, so genuinely unsupported formats still fail.

Common situations: User supplies a modern codec container the whitelist predates; file renamed without extension; downloaded audio in a format the pipeline's downstream ffmpeg settings don't support.

Related errors


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