🎥 Make videos programmatically with React
`@remotion/web-renderer`: Pass the frame rate to the video encoder
George Nick Gorzynskicea89d9ba728
diff --git a/packages/web-renderer/src/render-media-on-web.tsx b/packages/web-renderer/src/render-media-on-web.tsxindex 6bcecf3bfa..0483118fd9 100644--- a/packages/web-renderer/src/render-media-on-web.tsx+++ b/packages/web-renderer/src/render-media-on-web.tsx@@ -536,6 +536,9 @@ const internalRenderMediaOnWeb = async <// 1 packet per frame, + 33% buffer// https://mediabunny.dev/api/BaseTrackMetadata#maximumpacketcountmaximumPacketCount: Math.ceil(totalFrames * 1.33),+ // Mediabunny passes this to `VideoEncoder` as `framerate` and uses it+ // for the container timescale. Without it, Chromium assumes 30 fps.+ frameRate: resolved.fps,},);}diff --git a/packages/web-renderer/src/test/render-media.test.tsx b/packages/web-renderer/src/test/render-media.test.tsxindex c56dd38efb..25f636da06 100644--- a/packages/web-renderer/src/test/render-media.test.tsx+++ b/packages/web-renderer/src/test/render-media.test.tsx@@ -120,6 +120,38 @@ test('should render media to a writable stream', async (t) => {);});+test('should pass the composition frame rate to the video encoder', async (t) => {+ if (t.task.file.projectName === 'webkit') {+ t.skip();+ return;+ }++ const framerates: (number | undefined)[] = [];+ const originalConfigure = VideoEncoder.prototype.configure;+ VideoEncoder.prototype.configure = function (config) {+ framerates.push(config.framerate);+ return originalConfigure.call(this, config);+ };++ try {+ await renderMediaOnWeb({+ composition: {+ component: () => null,+ id: 'frame-rate-test',+ width: 100,+ height: 100,+ fps: 60,+ durationInFrames: 2,+ },+ inputProps: {},+ });+ } finally {+ VideoEncoder.prototype.configure = originalConfigure;+ }++ expect(framerates).toContain(60);+});+test('should reject invalid page responsiveness values', async () => {const Component: React.FC = () => null;