-
-
Notifications
You must be signed in to change notification settings - Fork 961
/
extract-audio.ts
31 lines (30 loc) 路 1.33 KB
/
extract-audio.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import {startLongRunningCompositor} from './compositor/compositor';
import type {LogLevel} from './log-level';
/**
* @description Extracts the audio from a video source and saves it at the specified output path without changing the audio format.
* @see [Documentation](https://remotion.dev/docs/renderer/extract-audio)
* @param options.videoSource The path to the video source from which the audio will be extracted.
* @param options.audioOutput The path where the extracted audio will be saved. Must use the correct file extension which matches the audio codec.
* @param options.logLevel The level of logging desired (optional).
* @param options.binariesDirectory The directory for binary dependencies (optional).
* @returns {Promise<void>} Resolves once the audio extraction is complete.
*/
export const extractAudio = async (options: {
videoSource: string;
audioOutput: string;
logLevel?: LogLevel;
binariesDirectory?: string | null;
}) => {
const compositor = startLongRunningCompositor({
maximumFrameCacheItemsInBytes: null,
logLevel: options?.logLevel ?? 'info',
indent: false,
binariesDirectory: options.binariesDirectory ?? null,
});
await compositor.executeCommand('ExtractAudio', {
input_path: options.videoSource,
output_path: options.audioOutput,
});
await compositor.finishCommands();
await compositor.waitForDone();
};