Skip to content

🎥 Make videos programmatically with React

`@remotion/renderer`: Be more lenient with `--scale` option

Jonny Burger5a54bda9a6b1
diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.ts
index 89c5b9d296..2742ed6e24 100644
--- a/packages/renderer/src/render-media.ts
+++ b/packages/renderer/src/render-media.ts
@@ -428,7 +428,7 @@ const internalRenderMediaRaw = ({
onCtrlCExit(`Delete ${workingDir}`, () => deleteDirectory(workingDir));
}
- validateEvenDimensionsWithCodec({
+ const {actualWidth, actualHeight} = validateEvenDimensionsWithCodec({
codec,
height: composition.height,
scale,
@@ -485,8 +485,8 @@ const internalRenderMediaRaw = ({
const createPrestitcherIfNecessary = () => {
if (preEncodedFileLocation) {
preStitcher = prespawnFfmpeg({
- width: composition.width * scale,
- height: composition.height * scale,
+ width: actualWidth,
+ height: actualHeight,
fps,
outputLocation: preEncodedFileLocation,
pixelFormat,
@@ -702,8 +702,8 @@ const internalRenderMediaRaw = ({
const stitchStart = Date.now();
return internalStitchFramesToVideo({
- width: composition.width * scale,
- height: composition.height * scale,
+ width: actualWidth,
+ height: actualHeight,
fps,
outputLocation: absoluteOutputLocation,
preEncodedFileLocation,
diff --git a/packages/renderer/src/validate-even-dimensions-with-codec.ts b/packages/renderer/src/validate-even-dimensions-with-codec.ts
index c430374b58..430dce99ba 100644
--- a/packages/renderer/src/validate-even-dimensions-with-codec.ts
+++ b/packages/renderer/src/validate-even-dimensions-with-codec.ts
@@ -20,8 +20,13 @@ export const validateEvenDimensionsWithCodec = ({
indent: boolean;
logLevel: LogLevel;
}) => {
+ let actualWidth = width * scale;
+ let actualHeight = height * scale;
if (wantsImageSequence) {
- return;
+ return {
+ actualWidth,
+ actualHeight,
+ };
}
if (
@@ -30,11 +35,12 @@ export const validateEvenDimensionsWithCodec = ({
codec !== 'h265' &&
codec !== 'h264-ts'
) {
- return;
+ return {
+ actualWidth,
+ actualHeight,
+ };
}
- let actualWidth = width * scale;
- let actualHeight = height * scale;
if (
actualWidth % 1 !== 0 &&
(actualWidth % 1 < 0.005 || actualWidth % 1 > 0.005)
@@ -82,4 +88,9 @@ export const validateEvenDimensionsWithCodec = ({
].join(' ');
throw new Error(message);
}
+
+ return {
+ actualWidth,
+ actualHeight,
+ };
};