Resample audio to 16kHz
For using Whisper, Whisper.cpp, @remotion/install-whisper-cpp
and Whisper.wasm, you need to provide a 16-bit, 16KHz, WAVE audio file.
This page describes approaches for converting your audio in the browser and on the server.
In the browser
You can use convertMedia()
to convert any of the supported video and audio formats and resample it to 16kHz.
💼 Important @remotion/webcodecs
License Disclaimer
This package is licensed under the Remotion License.
We consider a team of 4 or more people a "company".
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
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.
Resample audio to 16kHztsx
import {convertMedia ,canReencodeAudioTrack } from '@remotion/webcodecs';constoutput = awaitconvertMedia ({src : 'https://example.com/input.mp4',container : 'wav',onAudioTrack : async ({track }) => {if (awaitcanReencodeAudioTrack ({audioCodec : 'wav',track ,// Ignore this, bitrate is not used for WAV filesbitrate : 128000,sampleRate : 16000,})) {return {type : 'reencode',audioCodec : 'wav',bitrate : 128000,sampleRate : 16000,};}// If this conversion is not supported, return an errorreturn {type : 'fail',};},});constblob = awaitoutput .save (); // returns a `Blob`
On the server
You can use ffmpeg
to convert your audio to a 16-bit, 16KHz, WAVE file.
bash
ffmpeg -i /path/to/audio.mp4 -ar 16000 /path/to/audio.wav -y
If you don't want to install FFmpeg, you can also use the smaller FFmpeg binary provided by Remotion.
bash
npx remotion ffmpeg -i input.mp4 -ar 16000 output.wav -y
On remotion.dev/convert
If you are looking for a GUI, remotion.dev/convert is our free offering that allows you to convert your audio to a 16-bit, 16KHz, WAVE file, powered by @remotion/webcodecs
, offline and fast.