{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "frame-rate",
  "title": "Frame Rate",
  "description": "Reads the frame and the video config on a 30 fps timeline at any composition frame rate, so a scene keeps its timing in seconds and gains new in-between frames at 60 fps.",
  "dependencies": ["remotion"],
  "files": [
    {
      "path": "registry/remocn/frame-rate/index.ts",
      "content": "import { useMemo } from \"react\";\nimport { useCurrentFrame, useVideoConfig } from \"remotion\";\n\n// Every timing in remocn is written in frames of a 30 fps timeline: a delay\n// of 12, a rise over 20, a spring fed `fps`. Read straight from Remotion,\n// those numbers mean something else in a 60 fps composition: a tween runs\n// twice as fast, while a spring keeps its length, so a scene does not even\n// speed up evenly.\n//\n// These two hooks stand in for Remotion's and answer on that 30 fps timeline\n// whatever rate the composition runs at. At 60 fps the frame goes 0, 0.5, 1,\n// 1.5: the scene lasts the same number of seconds and every frame in between\n// is a new picture. At 30 fps they return exactly what Remotion does.\n//\n//   const frame = useSceneFrame();\n//   const { fps, width } = useSceneConfig();\n//\n// What a component hands back to Remotion is still counted in the\n// composition's own frames: `from` and `durationInFrames` of a `<Sequence>`,\n// the length of a transition. `useCompositionFrames()` converts those.\n\n/** The frame rate remocn timings are written in. */\nexport const SCENE_FPS = 30;\n\n/** `useCurrentFrame()` in 30 fps frames; fractional above 30 fps. */\nexport function useSceneFrame(): number {\n  const { fps } = useVideoConfig();\n  return (useCurrentFrame() * SCENE_FPS) / fps;\n}\n\n/**\n * `useVideoConfig()` on the 30 fps timeline: `fps` is 30 and\n * `durationInFrames` counts 30 fps frames. Size and the rest are untouched.\n */\nexport function useSceneConfig(): ReturnType<typeof useVideoConfig> {\n  const config = useVideoConfig();\n  return useMemo(\n    () => ({\n      ...config,\n      fps: SCENE_FPS,\n      durationInFrames: (config.durationInFrames * SCENE_FPS) / config.fps,\n    }),\n    [config],\n  );\n}\n\n/**\n * Turns a count of 30 fps frames into the composition's own, for what\n * Remotion itself reads: `<Sequence from={frames(24)}>`. Whole frames only,\n * as Remotion requires.\n */\nexport function useCompositionFrames(): (sceneFrames: number) => number {\n  const { fps } = useVideoConfig();\n  return useMemo(\n    () => (sceneFrames: number) => Math.round((sceneFrames * fps) / SCENE_FPS),\n    [fps],\n  );\n}\n\n/**\n * The other way round: a count Remotion gives a component in the\n * composition's own frames, in 30 fps frames. A transition's presentation\n * gets its length that way (`presentationDurationInFrames`).\n */\nexport function useSceneFrameCount(): (compositionFrames: number) => number {\n  const { fps } = useVideoConfig();\n  return useMemo(\n    () => (compositionFrames: number) => (compositionFrames * SCENE_FPS) / fps,\n    [fps],\n  );\n}\n",
      "type": "registry:lib",
      "target": "lib/remocn/frame-rate.ts"
    }
  ],
  "type": "registry:lib"
}
