NormalizeAudioLoudness: NaN loudness measurement poisons audio tensor, crashing AAC encoder on save
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- numpy, python
- Domain
- audio-video-rtc
Research direction
Read nodes_utility.py and locate loudness_norm, especially the integrated-loudness check and normalization call. Reproduce with very short or near-silent audio passed through NormalizeAudioLoudness; done means invalid loudness measurements leave the audio unchanged and the resulting output no longer causes the AAC save error.
Written by the indexing model from the issue text.
Description
When NormalizeAudioLoudness receives audio that is very short or near-silence, pyloudnorm's integrated loudness measurement returns NaN rather than a valid LUFS value. The existing guard only checks abs(loudness) > 100, which evaluates to False for NaN, so normalization proceeds — multiplying every sample by NaN and producing a fully NaN waveform tensor.
The node itself does not crash. The NaN tensor is silently passed downstream, and the error surfaces only when the video save node attempts to encode the audio with AAC:
!!! Exception during processing !!!
[Errno 22] Invalid argument: 'avcodec_send_frame()'; last error log: [aac] Input contains (near) NaN/+-Inf
...
av.error.ValueError: [Errno 22] Invalid argument: 'avcodec_send_frame()'; last error log: [aac] Input contains (near) NaN/+-Inf
Root cause:
In nodes_utility.py, loudness_norm:
loudness = meter.integrated_loudness(audio_array)
if abs(loudness) > 100: # abs(NaN) > 100 → False — guard does not fire
return audio_array
normalized_audio = pyloudnorm.normalize.loudness(audio_array, loudness, lufs)
"# gain = 10**((lufs - NaN) / 20) = NaN → entire array becomes NaN
Fix:
if not np.isfinite(loudness) or abs(loudness) > 100:
return audio_array
np.isfinite returns False for both NaN and inf, catching all invalid loudness measurements and returning the audio unchanged.
Reproduction:
Pass a very short or near-silent audio clip into NormalizeAudioLoudness, then connect its output to a video save node with audio. The save node will crash with the AAC NaN error above.
- Dominant language
- Python
- Stars
- 6.8k
- Forks
- 712
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from kijai/ComfyUI-WanVideoWrapper
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
kijai/ComfyUI-WanVideoWrapper#2060 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
kijai/ComfyUI-WanVideoWrapper#2055 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
kijai/ComfyUI-WanVideoWrapper#2046 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
kijai/ComfyUI-WanVideoWrapper#2058 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
kijai/ComfyUI-WanVideoWrapper#2057 ·
All issues in kijai/ComfyUI-WanVideoWrapper
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
OCA/account-invoicing#2529 ·
Maintainers usually reply within 1 day
-
area/ci
Difficulty 1/5 Under an hour Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
ImageGen generate-batch aborts valid JSONL jobs containing a Unicode line separator in poster textOpenbug imagen skills
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Email validation accepts a trailing newlinePossibly taken @marcello-pichini claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day