Skip to content

🎥 Make videos programmatically with React

fix the bug

Jonny Burger21f9071a3721
diff --git a/packages/cli/src/get-final-output-codec.ts b/packages/cli/src/get-final-output-codec.ts
index 27f1d13f99..740e452b2b 100644
--- a/packages/cli/src/get-final-output-codec.ts
+++ b/packages/cli/src/get-final-output-codec.ts
@@ -1,25 +1,25 @@
import type {Codec, CodecOrUndefined} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
-const fileExtensions: Record<string, Codec> = {
- webm: 'vp8',
- hevc: 'h265',
- mp3: 'mp3',
- mov: 'prores',
- wav: 'wav',
- aac: 'aac',
- mkv: 'h264-mkv',
- gif: 'gif',
- mp4: 'h264',
- m4a: 'aac',
+const fileExtensions: Record<string, Codec[]> = {
+ webm: ['vp8', 'vp9'],
+ hevc: ['h265'],
+ mp3: ['mp3'],
+ mov: ['prores'],
+ wav: ['wav'],
+ aac: ['aac'],
+ mkv: ['h264-mkv'],
+ gif: ['gif'],
+ mp4: ['h264'],
+ m4a: ['aac'],
};
const deriveExtensionFromFilename = (extension: string | null) => {
if (extension === null) {
- return null;
+ return [];
}
- return fileExtensions[extension] ?? null;
+ return fileExtensions[extension] ?? [];
};
export const getFinalOutputCodec = ({
@@ -43,49 +43,51 @@ export const getFinalOutputCodec = ({
const derivedOutNameCodec = deriveExtensionFromFilename(outNameExtension);
if (
- derivedDownloadCodec &&
- derivedOutNameCodec &&
- derivedDownloadCodec !== derivedOutNameCodec
+ derivedDownloadCodec.length === 0 &&
+ derivedOutNameCodec.length === 0 &&
+ derivedDownloadCodec.join('') !== derivedOutNameCodec.join('')
) {
throw new TypeError(
`The download name is ${downloadName} but the output name is ${outName}. The file extensions must match`
);
}
- if (derivedDownloadCodec) {
- if (cliFlag && derivedDownloadCodec !== cliFlag) {
+ if (cliFlag) {
+ if (
+ derivedDownloadCodec.length > 0 &&
+ derivedDownloadCodec.indexOf(cliFlag) === -1
+ ) {
throw new TypeError(
- `The download name is ${downloadName} but --codec=${cliFlag} was passed. The download name implies a codec of ${derivedDownloadCodec} which does not align with the --codec flag.`
+ `The download name is ${downloadName} but --codec=${cliFlag} was passed. The download name implies a codec of ${derivedDownloadCodec.join(
+ ' or '
+ )} which does not align with the --codec flag.`
);
}
- return {
- codec: derivedDownloadCodec,
- reason: 'derived from download name',
- };
- }
-
- if (derivedOutNameCodec) {
- if (cliFlag && derivedOutNameCodec !== cliFlag) {
+ if (
+ derivedOutNameCodec.length > 0 &&
+ derivedOutNameCodec.indexOf(cliFlag) === -1
+ ) {
throw new TypeError(
`The out name is ${outName} but --codec=${cliFlag} was passed. The out name implies a codec of ${derivedOutNameCodec} which does not align with the --codec flag.`
);
}
- if (configFile && derivedOutNameCodec !== configFile) {
- throw new TypeError(
- `The out name is ${outName} but ${configFile} was set as the codec in the config file. The out name implies a codec of ${derivedOutNameCodec} which does not align with the codec set in the config file.`
- );
- }
+ return {codec: cliFlag, reason: 'from --codec flag'};
+ }
+ if (derivedDownloadCodec) {
return {
- codec: derivedOutNameCodec,
- reason: 'derived from out name',
+ codec: derivedDownloadCodec[0],
+ reason: 'derived from download name',
};
}
- if (cliFlag) {
- return {codec: cliFlag, reason: 'from --codec flag'};
+ if (derivedOutNameCodec) {
+ return {
+ codec: derivedOutNameCodec[0],
+ reason: 'derived from out name',
+ };
}
if (configFile) {