packages/docs/docs/renderer/extract-audio.mdx
Extracts the audio from a video source and saves it to the specified output path. It does not convert the audio to a different format.
import {resolve} from 'node:path';
import {extractAudio} from '@remotion/renderer';
const videoSource = resolve(process.cwd(), '/Users/john/path-to-video.mp4');
const audioOutput = resolve(process.cwd(), './output-audio-path.mp3');
await extractAudio({
videoSource,
audioOutput,
});
:::info
Pass an absolute path to extractAudio(). URLs are not supported.
:::
An object containing the following properties:
videoSourcestring
The path to the video source from which the audio will be extracted.
audioOutputstring
The path where the extracted audio will be saved. The file extension must match the audio codec. Use Mediabunny to get video metadata to determine the container and therefore the appropriate file extension.
logLevel?binariesDirectory?<AvailableFrom v="4.0.120" />The function returns a Promise<void>, which resolves once the audio extraction is complete.