Skip to main content

convertAudioData()v4.0.288

属于 @remotion/webcodecs 软件包的一部分.

🌐 Part of the @remotion/webcodecs package.

💼 重要许可免责声明
This package is licensed under the Remotion License.
We consider a team of 4 or more people a "company".

For "companies": A Remotion Company license needs to be obtained to use this package.
In a future version of @remotion/webcodecs, this package will also require the purchase of a newly created "WebCodecs Conversion Seat". Get in touch with us if you are planning to use this package.

For individuals and teams up to 3: You can use this package for free.

This is a short, non-binding explanation of our license. See the License itself for more details.

AudioData 对象转换为一个新的 AudioData 对象,具有不同的采样率或格式,或两者兼有。

🌐 Converts an AudioData object to a new AudioData object with a different sample rate or format, or both.

Converting an audio data
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, } */

行为

🌐 Behavior

  • 可能会进行四舍五入。
  • 新的采样率必须在3000到768000之间。
  • 如果不需要转换(采样率和格式相同),则会克隆原始的 AudioData
  • 对输入或输出 AudioData 都不会进行任何清理(请自行对它们调用 close())。

应用编程接口

🌐 API

接受具有以下属性的对象:

🌐 Takes an object with the following properties:

audioData

要转换的AudioData对象。

🌐 The AudioData object to convert.

newSampleRate?

新的采样率。必须在3000到768000之间(实际上只有Chrome会强制执行,但Remotion总是会抛出错误)。

🌐 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.

另请参阅

🌐 See also