Skip to content

🎥 Make videos programmatically with React

@remotion/studio: Use the renderer extension parser in render validation

Jonny Burger0c1945ca7262
diff --git a/packages/renderer/src/client.ts b/packages/renderer/src/client.ts
index 8bd978a938..95d7ff9356 100644
--- a/packages/renderer/src/client.ts
+++ b/packages/renderer/src/client.ts
@@ -11,6 +11,7 @@ import {
defaultCodecsForFileExtension,
getFileExtensionFromCodec,
} from './get-extension-from-codec';
+import {getExtensionOfFilename} from './get-extension-of-filename';
import {validStillImageFormats, validVideoImageFormats} from './image-format';
import {DEFAULT_JPEG_QUALITY} from './jpeg-quality';
import {logLevels} from './log-level';
@@ -52,6 +53,7 @@ export {HardwareAccelerationOption} from './options/hardware-acceleration';
export {ProResProfile} from './options/prores-profile';
export const BrowserSafeApis = {
+ getExtensionOfFilename,
getFileExtensionFromCodec,
validCodecs,
validAudioCodecs,
diff --git a/packages/studio/src/components/RenderModal/out-name-checker.ts b/packages/studio/src/components/RenderModal/out-name-checker.ts
index 8dd45bf905..b2aa5a75cb 100644
--- a/packages/studio/src/components/RenderModal/out-name-checker.ts
+++ b/packages/studio/src/components/RenderModal/out-name-checker.ts
@@ -60,8 +60,11 @@ const isValidOutName = ({
stillImageFormat: StillImageFormat | null;
separateAudioTo: string | null;
}): void => {
- const extension = outName.substring(outName.lastIndexOf('.') + 1);
- const prefix = outName.substring(0, outName.lastIndexOf('.'));
+ const extension = BrowserSafeApis.getExtensionOfFilename(outName);
+ const prefix =
+ extension === null
+ ? outName
+ : outName.substring(0, outName.length - extension.length - 1);
const map = BrowserSafeApis.defaultFileExtensionMap[codec];
@@ -93,7 +96,7 @@ const isValidOutName = ({
BrowserSafeApis.validateOutputFilename({
codec,
audioCodecSetting: audioCodec ?? null,
- extension,
+ extension: extension ?? '',
preferLossless: false,
separateAudioTo,
});
@@ -116,16 +119,16 @@ const isValidOutName = ({
if (
renderMode === 'still' &&
stillImageFormat &&
- !isValidStillExtension(extension, stillImageFormat)
+ !isValidStillExtension(extension ?? '', stillImageFormat)
) {
throw new Error(
- `The extension ${extension} is not supported for still image format ${stillImageFormat}`,
+ `The extension ${extension ?? ''} is not supported for still image format ${stillImageFormat}`,
);
}
if (renderMode === 'sequence') {
- if (outName.includes('.')) {
- throw new Error('Folder names must not contain a dot');
+ if (extension !== null) {
+ throw new Error('The image sequence folder must not have an extension');
}
}
};