Skip to content

🎥 Make videos programmatically with React

Accept uppercase output file extensions in render validation

theluckystrikecb6101bd4e09
diff --git a/packages/renderer/src/options/video-codec.tsx b/packages/renderer/src/options/video-codec.tsx
index 14868d0469..b046f03234 100644
--- a/packages/renderer/src/options/video-codec.tsx
+++ b/packages/renderer/src/options/video-codec.tsx
@@ -41,9 +41,13 @@ const deriveCodecsFromFilename = (
return {possible: [], default: null};
}
+ const normalizedExtension = extension.toLowerCase();
+
return {
- default: defaultCodecsForFileExtension[extension as FileExtension] ?? null,
- possible: makeFileExtensionMap()[extension] ?? [],
+ default:
+ defaultCodecsForFileExtension[normalizedExtension as FileExtension] ??
+ null,
+ possible: makeFileExtensionMap()[normalizedExtension] ?? [],
};
};
diff --git a/packages/renderer/src/validate-output-filename.ts b/packages/renderer/src/validate-output-filename.ts
index e9282ec28e..895e4858cc 100644
--- a/packages/renderer/src/validate-output-filename.ts
+++ b/packages/renderer/src/validate-output-filename.ts
@@ -14,7 +14,7 @@ export const validateOutputFilename = <T extends Codec>({
}: {
codec: T;
audioCodecSetting: AudioCodec | null;
- extension: string;
+ extension: string | null;
preferLossless: boolean;
separateAudioTo: string | null;
}) => {
@@ -26,10 +26,14 @@ export const validateOutputFilename = <T extends Codec>({
);
}
+ // File extensions are case-insensitive: `out.MP4` is a valid MP4 output.
+ const normalizedExtension =
+ extension === null ? null : extension.toLowerCase();
+
if (
NoReactInternals.ENABLE_V5_BREAKING_CHANGES &&
codec === 'aac' &&
- (extension.toLowerCase() === 'mpg' || extension.toLowerCase() === 'mpeg')
+ (normalizedExtension === 'mpg' || normalizedExtension === 'mpeg')
) {
throw new Error(
'AAC output with .mpg or .mpeg extensions is not supported. Use .aac for raw ADTS AAC or .m4a for an MPEG-4 audio container.',
@@ -45,7 +49,7 @@ export const validateOutputFilename = <T extends Codec>({
});
if (resolvedAudioCodec === null) {
- if (extension !== map.default) {
+ if (normalizedExtension !== map.default) {
throw new TypeError(
`When using the ${codec} codec, the output filename must end in .${map.default}.`,
);
@@ -66,7 +70,7 @@ export const validateOutputFilename = <T extends Codec>({
].possible;
if (
- !acceptableExtensions.includes(extension as FileExtension) &&
+ !acceptableExtensions.includes(normalizedExtension as FileExtension) &&
!separateAudioTo
) {
throw new TypeError(