`@remotion/media-utils`: `visualizeAudio()` returns non-silent spectrum values for frames before the audio starts#13446
When visualizeAudio() is called for a time before the audio starts (a negative frame when an <Audio> track is delayed in a <Sequence>, or frame / fps < dataOffsetInSeconds), it returns the spectrum of the beginning of the audio track instead of silence (0s). After the audio ends, visualizeAudio() returns all zeros as expected.
Reproduction
@remotion/media-utils 4.0.544 and main, with a 2-second 440 Hz sine wave at 8000 Hz (fps: 30, numberOfSamples: 16):
| Call | Expected | Actual |
|---|---|---|
frame: -30 (1 s before audio) | [0, 0, ..., 0] | [0.199, 0.328, 0.346, 0.269, ...] |
frame: 0, dataOffsetInSeconds: 1 | [0, 0, ..., 0] | [0.199, 0.328, 0.346, 0.269, ...] |
frame: 90 (1 s after audio) | [0, 0, ..., 0] | [0, 0, ..., 0] |
Both optimizeFor: "accuracy" and optimizeFor: "speed" behave the same way. The docs instruct shifting when the audio is offset on the timeline, so every frame of a silent lead-in displays a frozen non-zero spectrum from sample .