Skip to content

🎥 Make videos programmatically with React

`@remotion/renderer`: Fix uneven dimensions failing FFmpeg

JonnyBurgerb70424b454ed
diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.ts
index 6201070d56..6b42177cd9 100644
--- a/packages/renderer/src/render-media.ts
+++ b/packages/renderer/src/render-media.ts
@@ -201,7 +201,7 @@ const internalRenderMediaRaw = ({
proResProfile,
x264Preset,
crf,
- composition,
+ composition: compositionWithPossibleUnevenDimensions,
serializedInputPropsWithCustomSchema,
pixelFormat: userPixelFormat,
codec,
@@ -256,12 +256,14 @@ const internalRenderMediaRaw = ({
offthreadVideoThreads,
}: InternalRenderMediaOptions): Promise<RenderMediaResult> => {
const pixelFormat =
- userPixelFormat ?? composition.defaultPixelFormat ?? DEFAULT_PIXEL_FORMAT;
+ userPixelFormat ??
+ compositionWithPossibleUnevenDimensions.defaultPixelFormat ??
+ DEFAULT_PIXEL_FORMAT;
if (repro) {
enableRepro({
serveUrl,
- compositionName: composition.id,
+ compositionName: compositionWithPossibleUnevenDimensions.id,
serializedInputPropsWithCustomSchema,
serializedResolvedPropsWithCustomSchema,
});
@@ -331,8 +333,8 @@ const internalRenderMediaRaw = ({
const {estimatedUsage, freeMemory, hasEnoughMemory} =
shouldUseParallelEncoding({
- height: composition.height,
- width: composition.width,
+ height: compositionWithPossibleUnevenDimensions.height,
+ width: compositionWithPossibleUnevenDimensions.width,
logLevel,
});
const parallelEncoding =
@@ -413,7 +415,7 @@ const internalRenderMediaRaw = ({
const imageFormat: VideoImageFormat = isAudioCodec(codec)
? 'none'
: (provisionalImageFormat ??
- composition.defaultVideoImageFormat ??
+ compositionWithPossibleUnevenDimensions.defaultVideoImageFormat ??
DEFAULT_VIDEO_IMAGE_FORMAT);
validateSelectedPixelFormatAndImageFormatCombination(
@@ -438,14 +440,20 @@ const internalRenderMediaRaw = ({
const {actualWidth, actualHeight} = validateEvenDimensionsWithCodec({
codec,
- height: composition.height,
+ height: compositionWithPossibleUnevenDimensions.height,
scale,
- width: composition.width,
+ width: compositionWithPossibleUnevenDimensions.width,
wantsImageSequence: false,
indent,
logLevel,
});
+ const composition = {
+ ...compositionWithPossibleUnevenDimensions,
+ height: actualHeight,
+ width: actualWidth,
+ };
+
const realFrameRange = getRealFrameRange(
composition.durationInFrames,
frameRange,