remotion-dev/remotion · error
Pitch shifter was not initialized.
Error message
Pitch shifter was not initialized.
What it means
Inside pitchShiftAudioIterator, the shifter is created lazily when a segment starts. The null check before append is a defensive invariant: if control flow ever reaches append without a shifter having been constructed, it throws this error. It should be unreachable in normal use and indicates corrupted segment/state handling in the streaming pipeline.
Source
Thrown at packages/media/src/audio/pitch-shift.ts:614
const previousSegmentFinalSlice = flush();
if (previousSegmentFinalSlice) {
yield previousSegmentFinalSlice;
}
sampleRate = nextSampleRate;
numberOfChannels = nextNumberOfChannels;
segmentStart = slice.timelineTimestamp;
segmentInputFrames = 0;
segmentOutputFrames = 0;
shifter = new StreamingPitchShifter({
numberOfChannels,
sampleRate,
toneFrequency,
});
}
if (!shifter) {
throw new Error('Pitch shifter was not initialized.');
}
segmentInputFrames += planar[0].length;
const output = shifter.append(planar);
if (output[0].length > 0) {
yield makeAudioBufferSlice({
audio: output,
timelineTimestamp: segmentStart + segmentOutputFrames / sampleRate,
sampleRate,
});
segmentOutputFrames += output[0].length;
}
}
const finalSlice = flush();
if (finalSlice) {
yield finalSlice;
}View on GitHub (pinned to a6a7485a9a)
Solutions
- Use pitchShiftAudioIterator unmodified with a valid audio iterator as input
- Ensure yielded slices have real buffers with valid sampleRate/numberOfChannels (skip empty slices)
- Upgrade @remotion/media to latest — if reachable, it is a bug worth reporting
- Do not mix internal pitch-shift helpers from different package versions
Defensive patterns
Strategy: validation
Validate before calling
// Only feed valid slices into pitchShiftAudioIterator
for await (const slice of iterator) {
if (!slice.buffer.buffer || slice.buffer.buffer.sampleRate <= 0) continue;
} Try / catch
try {
yield* pitchShiftAudioIterator(audioIterator, toneFrequency);
} catch (e) {
if (e instanceof Error && e.message === 'Pitch shifter was not initialized.') {
console.error('Pitch shift pipeline received malformed audio segments');
} else throw e;
} Prevention
- Use pitchShiftAudioIterator unmodified from @remotion/media
- Feed it a well-formed AudioBufferIterator with valid sampleRate/numberOfChannels
- Skip or filter empty/malformed slices upstream
- Do not mix internal pitch-shift helpers across package versions
When it happens
Trigger: Custom or patched iterator code reaching the append call while startsNewSegment failed to create a shifter; calling pitchShiftAudioIterator internals with an iterator that yields slices lacking valid sampleRate/numberOfChannels so shifter construction paths are bypassed.
Common situations: Forked/modified versions of pitchShiftAudioIterator; feeding empty or malformed audio buffers; upgrading @remotion/media and mixing internal helpers across versions.
Related errors
- Cannot append audio after the time stretcher was finalized.
- The time stretcher has already been finalized.
- No audio stream found in '${input_path}'. Ensure the video c
- Could not determine duration of ${src}, but "loop" was set.
- No audio track found
AI-assisted analysis of remotion-dev/remotion@a6a7485a9a (2026-09-02).
Data as JSON: /api/errors/b89a1470d84f96a4.
Report an issue: GitHub.