Skip to content

🎥 Make videos programmatically with React

`@remotion/renderer`: Fix imprecise FPS when combining chunks

Jonny Burgerc81c702feba6
diff --git a/packages/renderer/src/mux-video-and-audio.ts b/packages/renderer/src/mux-video-and-audio.ts
index 5cbce21df8..3e0a3dce5e 100644
--- a/packages/renderer/src/mux-video-and-audio.ts
+++ b/packages/renderer/src/mux-video-and-audio.ts
@@ -47,6 +47,11 @@ export const muxVideoAndAudio = async ({
videoOutput ? 'copy' : null,
audioOutput ? '-c:a' : null,
audioOutput ? 'copy' : null,
+ // Set the exact output framerate to prevent drift when combining chunks.
+ // Without this, ffmpeg infers the framerate from the stream which can
+ // result in slightly imprecise values like 95940000/3197999 instead of 30/1.
+ videoOutput ? '-r' : null,
+ videoOutput ? String(fps) : null,
numberOfGifLoops === null ? null : '-loop',
numberOfGifLoops === null
? null