FPS converter
This snippet is useful if you have designed your video with a different frame rate than you want to render in the end. Wrap your markup in the <FpsConverter>
component override the time of it's children to achieve a different FPS.
FpsConverter.tsxtsx
importReact , {useContext ,useMemo } from "react";import {Internals ,TimelineContextValue ,useVideoConfig } from "remotion";export constFpsConverter :React .FC <{originalFps : number;newFps : number;children :React .ReactNode ;}> = ({originalFps ,newFps ,children }) => {constcontext =useContext (Internals .Timeline .TimelineContext );constratio =originalFps /newFps ;const {id } =useVideoConfig ();constvalue :TimelineContextValue =useMemo (() => {return {...context ,// Remotion 4.0frame : { [id ]: (context .frame [id ] ?? 0) *ratio },// Remotion 3.0// frame: context.frame * ratio,};}, [context ,ratio ]);return (<Internals .Timeline .TimelineContext .Provider value ={value }>{children }</Internals .Timeline .TimelineContext .Provider >);};
FpsConverter.tsxtsx
importReact , {useContext ,useMemo } from "react";import {Internals ,TimelineContextValue ,useVideoConfig } from "remotion";export constFpsConverter :React .FC <{originalFps : number;newFps : number;children :React .ReactNode ;}> = ({originalFps ,newFps ,children }) => {constcontext =useContext (Internals .Timeline .TimelineContext );constratio =originalFps /newFps ;const {id } =useVideoConfig ();constvalue :TimelineContextValue =useMemo (() => {return {...context ,// Remotion 4.0frame : { [id ]: (context .frame [id ] ?? 0) *ratio },// Remotion 3.0// frame: context.frame * ratio,};}, [context ,ratio ]);return (<Internals .Timeline .TimelineContext .Provider value ={value }>{children }</Internals .Timeline .TimelineContext .Provider >);};
Usagetsx
export const Converted: React.FC = () => {return (<FpsConverter newFps={29.97} originalFps={60}><MyComp></MyComp></FpsConverter>);};
Usagetsx
export const Converted: React.FC = () => {return (<FpsConverter newFps={29.97} originalFps={60}><MyComp></MyComp></FpsConverter>);};