packages/docs/docs/webcodecs/convert-audiodata.mdx
:::warning We are phasing out Remotion WebCodecs and are moving to Mediabunny! :::
Part of the @remotion/webcodecs package.
import {LicenseDisclaimer} from './LicenseDisclaimer';
<details> <summary>💼 Important License Disclaimer</summary> <LicenseDisclaimer /> </details>Converts an AudioData object to a new AudioData object with a different sample rate or format, or both.
import {convertAudioData} from '@remotion/webcodecs';
const audioData = new AudioData({
data: new Int32Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]),
format: 's32',
numberOfChannels: 1,
numberOfFrames: 10,
sampleRate: 44100,
timestamp: 0,
});
const newAudioData = convertAudioData({audioData, newSampleRate: 22050});
/*
{
data: [0, 2, 4, 6, 8],
format: 's32',
numberOfChannels: 1,
numberOfFrames: 5,
sampleRate: 22050,
timestamp: 0,
}
*/
AudioData is cloned.AudioData (call close() on them yourself).Takes an object with the following properties:
audioDataThe AudioData object to convert.
newSampleRate?The new sample rate. Must be between 3000 and 768000 (only Chrome enforces this technically, but Remotion will throw an error always).
newFormat?The new format.