Skip to content

🎥 Make videos programmatically with React

add allowed audio codecs

Jonny Burgerf736a1336baa
diff --git a/packages/cli/src/get-filename.ts b/packages/cli/src/get-filename.ts
index 4e0a018df0..aac21c5eed 100644
--- a/packages/cli/src/get-filename.ts
+++ b/packages/cli/src/get-filename.ts
@@ -56,6 +56,31 @@ export const getOutputFilename = (
process.exit(1);
}
}
+ if (codec === 'mp3') {
+ if (extension !== 'mp3') {
+ console.error("When using the 'mp3' codec, the output must end in .mp3");
+ process.exit(1);
+ }
+ }
+ if (codec === 'aac') {
+ const allowedAacExtensions = ['aac', '3gp', 'm4a', 'm4b', 'mpg', 'mpeg'];
+ if (!extension || !allowedAacExtensions.includes(extension)) {
+ console.error(
+ `When using the 'aac' codec, the output must end in one of those extensions: ${allowedAacExtensions
+ .map((a) => `.${a}`)
+ .join(', ')}`
+ );
+ process.exit(1);
+ }
+ }
+ if (codec === 'wav') {
+ if (extension !== 'wav') {
+ console.error(
+ "When using the 'wav' codec, the output locatio must end in .wav."
+ );
+ process.exit(1);
+ }
+ }
return filename;
};
diff --git a/packages/core/src/config/codec.ts b/packages/core/src/config/codec.ts
index 05a07a1682..6ff559cc1a 100644
--- a/packages/core/src/config/codec.ts
+++ b/packages/core/src/config/codec.ts
@@ -1,4 +1,12 @@
-const validCodecs = ['h264', 'h265', 'vp8', 'vp9'] as const;
+const validCodecs = [
+ 'h264',
+ 'h265',
+ 'vp8',
+ 'vp9',
+ 'mp3',
+ 'aac',
+ 'wav',
+] as const;
export type Codec = typeof validCodecs[number];
export type CodecOrUndefined = Codec | undefined;