{"record":{"id":"4442e86c4273cd65","repo":"harry0703/MoneyPrinterTurbo","slug":"unsupported-custom-audio-type-audio-extension-or","errorCode":null,"errorMessage":"unsupported custom audio type {audio_extension or '<none>'}; allowed extensions: {allowed}","messagePattern":"unsupported custom audio type (.+?); allowed extensions: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"cli.py","lineNumber":673,"sourceCode":"    from app.services import bgm as bgm_service\n    from app.utils import utils\n\n    local_material_extensions = {\n        *(f\".{extension}\" for extension in const.FILE_TYPE_VIDEOS),\n        *(f\".{extension}\" for extension in const.FILE_TYPE_IMAGES),\n        \".avi\",\n        \".flv\",\n    }\n\n    if params.custom_audio_file:\n        params.custom_audio_file = _resolve_cli_file(\n            params.custom_audio_file,\n            description=\"custom audio\",\n        )\n        audio_extension = os.path.splitext(params.custom_audio_file)[1].lower()\n        if audio_extension not in _CUSTOM_AUDIO_EXTENSIONS:\n            allowed = \", \".join(sorted(_CUSTOM_AUDIO_EXTENSIONS))\n            raise ValueError(\n                f\"unsupported custom audio type {audio_extension or '<none>'}; \"\n                f\"allowed extensions: {allowed}\"\n            )\n\n    if params.bgm_type == \"custom\":\n        if not bgm_service.should_use_bgm(params.bgm_type, params.bgm_volume):\n            # 0 音量时下游会统一跳过所有 BGM。这里同时清空文件参数，避免\n            # CLI 为一个不会被读取的文件执行路径解析、存在性检查或格式\n            # 校验。\n            params.bgm_file = \"\"\n        elif not params.bgm_file:\n            # 缺少文件是否构成错误取决于通用 BGM 开关，不能在 argparse 阶段\n            # 无条件拦截，否则 ``custom + 0%`` 会和 WebUI、服务层行为不一致。\n            raise ValueError(\"--bgm-file is required when --bgm-type is custom\")\n        else:\n            try:\n                # CLI、WebUI 和任务服务必须共用同一个 BGM 文件边界。这里直接\n                # 复用服务层解析，既支持用户上传目录和内置歌曲目录，也","sourceCodeStart":655,"sourceCodeEnd":691,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/cli.py#L655-L691","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Convert the audio to a whitelisted extension first, e.g. ffmpeg -i in.opus out.mp3.","Rename the file to carry its true, whitelisted extension if the content is already a supported format.","As a maintainer, extend _CUSTOM_AUDIO_EXTENSIONS after verifying downstream ffmpeg/moviepy handles the new format."],"exampleFix":"# before\npython cli.py --custom-audio bgm.opus\n\n# after\nffmpeg -i bgm.opus bgm.mp3\npython cli.py --custom-audio bgm.mp3","handlingStrategy":"validation","validationCode":"import os\n_ALLOWED = {\".mp3\", \".wav\", \".flac\", \".ogg\", \".m4a\"}  # mirror _CUSTOM_AUDIO_EXTENSIONS from cli.py\next = os.path.splitext(params.custom_audio_file)[1].lower()\nif ext not in _ALLOWED:\n    raise ValueError(f\"convert {params.custom_audio_file} to one of {sorted(_ALLOWED)}\")","typeGuard":"def is_supported_custom_audio(path: str) -> bool:\n    return os.path.splitext(path)[1].lower() in _CUSTOM_AUDIO_EXTENSIONS","tryCatchPattern":null,"preventionTips":["Standardize uploads on mp3/wav before running the pipeline.","Keep the extension whitelist and downstream ffmpeg capabilities in sync when you extend it."],"tags":["cli","audio","validation","file-format"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}