ComfyUI/comfy_api
nahcmon 39f62a0d4c Fix SaveAudioMP3 avcodec_open2 EINVAL crashes
Two separate bugs in AudioSaveHelper.save_audio caused libmp3lame's
avcodec_open2 to fail with EINVAL ([Errno 22] Invalid argument):

1. codec_context.qscale is exposed by PyAV as a bool flag rather than
   the int quality scale libmp3lame expects, so assigning a level (1)
   to it for "V0" quality made avcodec_open2 reject the codec context.
   libmp3lame's default VBR mode is roughly equivalent to V0 quality,
   so the assignment is simply removed.

2. libmp3lame only accepts a fixed set of sample rates (8000, 11025,
   12000, 16000, 22050, 24000, 32000, 44100, 48000 Hz). Audio sources
   that output other rates (e.g. 40000 Hz from some RVC models) were
   passed through unchanged, causing avcodec_open2 to fail. MP3 output
   now remaps to the closest supported rate and resamples, mirroring
   the existing Opus rate-handling logic.

Verified by reproducing both failures directly against PyAV with the
unpatched code and confirming the patched AudioSaveHelper.save_audio
encodes successfully for both the "V0" quality and 40 kHz cases.

Fixes #13937
2026-06-08 18:30:35 +02:00
..
input range type (#13322) 2026-04-23 20:51:34 -07:00
input_impl ComfyAPI Core v0.0.2 (#8962) 2025-07-29 22:17:22 -04:00
internal comfy_api: remove usage of "Type","List" and "Dict" types (#11238) 2025-12-15 16:01:10 -08:00
latest Fix SaveAudioMP3 avcodec_open2 EINVAL crashes 2026-06-08 18:30:35 +02:00
torch_helpers Make torch.compile LoRA/key-compatible (#8213) 2025-05-21 04:56:56 -04:00
util ComfyAPI Core v0.0.2 (#8962) 2025-07-29 22:17:22 -04:00
v0_0_1 ComfyAPI Core v0.0.2 (#8962) 2025-07-29 22:17:22 -04:00
v0_0_2 Add MatchType, DynamicCombo, and Autogrow support to V3 Schema (#10832) 2025-12-03 00:17:13 -05:00
feature_flags.py feat: add generic --feature-flag CLI arg and --list-feature-flags registry (#13685) 2026-05-04 19:50:26 -07:00
generate_api_stubs.py ComfyAPI Core v0.0.2 (#8962) 2025-07-29 22:17:22 -04:00
util.py ComfyAPI Core v0.0.2 (#8962) 2025-07-29 22:17:22 -04:00
version_list.py comfy_api: remove usage of "Type","List" and "Dict" types (#11238) 2025-12-15 16:01:10 -08:00