page.tsx 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. import { Code } from "@/components/code";
  2. export const metadata = {
  3. title: "@json-render/remotion API | json-render",
  4. };
  5. export default function RemotionApiPage() {
  6. return (
  7. <article>
  8. <h1 className="text-3xl font-bold mb-4">@json-render/remotion</h1>
  9. <p className="text-muted-foreground mb-8">
  10. Remotion video renderer. Turn JSON timeline specs into video
  11. compositions.
  12. </p>
  13. <h2 className="text-xl font-semibold mt-12 mb-4">schema</h2>
  14. <p className="text-sm text-muted-foreground mb-4">
  15. The timeline schema for video specs. Use with{" "}
  16. <code className="text-foreground">defineCatalog</code> from core.
  17. </p>
  18. <Code lang="typescript">{`import { defineCatalog } from '@json-render/core';
  19. import { schema, standardComponentDefinitions } from '@json-render/remotion';
  20. const catalog = defineCatalog(schema, {
  21. components: standardComponentDefinitions,
  22. transitions: standardTransitionDefinitions,
  23. effects: standardEffectDefinitions,
  24. });`}</Code>
  25. <h2 className="text-xl font-semibold mt-12 mb-4">Renderer</h2>
  26. <p className="text-sm text-muted-foreground mb-4">
  27. The main composition component that renders timeline specs. Use with
  28. Remotion&apos;s Player or in a Remotion project.
  29. </p>
  30. <Code lang="tsx">{`import { Player } from '@remotion/player';
  31. import { Renderer } from '@json-render/remotion';
  32. function VideoPlayer({ spec }) {
  33. return (
  34. <Player
  35. component={Renderer}
  36. inputProps={{ spec }}
  37. durationInFrames={spec.composition.durationInFrames}
  38. fps={spec.composition.fps}
  39. compositionWidth={spec.composition.width}
  40. compositionHeight={spec.composition.height}
  41. controls
  42. />
  43. );
  44. }`}</Code>
  45. <h3 className="text-lg font-semibold mt-8 mb-4">Custom Components</h3>
  46. <p className="text-sm text-muted-foreground mb-4">
  47. Pass custom components to the Renderer:
  48. </p>
  49. <Code lang="tsx">{`import { Renderer, standardComponents } from '@json-render/remotion';
  50. const customComponents = {
  51. ...standardComponents,
  52. MyCustomClip: ({ clip }) => <div>{clip.props.text}</div>,
  53. };
  54. <Player
  55. component={Renderer}
  56. inputProps={{ spec, components: customComponents }}
  57. // ...
  58. />`}</Code>
  59. <h2 className="text-xl font-semibold mt-12 mb-4">Standard Components</h2>
  60. <p className="text-sm text-muted-foreground mb-4">
  61. Pre-built video components included in the package:
  62. </p>
  63. <Code lang="typescript">{`import {
  64. TitleCard, // Full-screen title with subtitle
  65. ImageSlide, // Full-screen image display
  66. SplitScreen, // Two-column layout
  67. QuoteCard, // Quote with attribution
  68. StatCard, // Large statistic display
  69. LowerThird, // Name/title overlay
  70. TextOverlay, // Centered text overlay
  71. TypingText, // Terminal typing animation
  72. LogoBug, // Corner logo watermark
  73. VideoClip, // Video playback
  74. } from '@json-render/remotion';`}</Code>
  75. <h3 className="text-lg font-semibold mt-8 mb-4">TitleCard Props</h3>
  76. <Code lang="typescript">{`{
  77. title: string;
  78. subtitle?: string;
  79. backgroundColor?: string; // default: "#1a1a1a"
  80. textColor?: string; // default: "#ffffff"
  81. }`}</Code>
  82. <h3 className="text-lg font-semibold mt-8 mb-4">TypingText Props</h3>
  83. <Code lang="typescript">{`{
  84. text: string;
  85. charsPerSecond?: number; // default: 15
  86. showCursor?: boolean; // default: true
  87. cursorChar?: string; // default: "|"
  88. fontFamily?: string; // default: "monospace"
  89. fontSize?: number; // default: 48
  90. textColor?: string; // default: "#00ff00"
  91. backgroundColor?: string; // default: "#1e1e1e"
  92. }`}</Code>
  93. <h2 className="text-xl font-semibold mt-12 mb-4">Catalog Definitions</h2>
  94. <p className="text-sm text-muted-foreground mb-4">
  95. Pre-built definitions for creating catalogs:
  96. </p>
  97. <Code lang="typescript">{`import {
  98. standardComponentDefinitions, // All standard component definitions
  99. standardTransitionDefinitions, // fade, slideLeft, slideRight, etc.
  100. standardEffectDefinitions, // kenBurns, pulseGlow, colorShift
  101. } from '@json-render/remotion';
  102. // Use in your catalog
  103. const catalog = defineCatalog(schema, {
  104. components: {
  105. ...standardComponentDefinitions,
  106. // Add custom components
  107. },
  108. transitions: standardTransitionDefinitions,
  109. effects: standardEffectDefinitions,
  110. });`}</Code>
  111. <h2 className="text-xl font-semibold mt-12 mb-4">
  112. Hooks &amp; Utilities
  113. </h2>
  114. <h3 className="text-lg font-semibold mt-8 mb-4">useTransition</h3>
  115. <p className="text-sm text-muted-foreground mb-4">
  116. Calculate transition styles for a clip based on current frame:
  117. </p>
  118. <Code lang="typescript">{`import { useTransition } from '@json-render/remotion';
  119. import { useCurrentFrame } from 'remotion';
  120. function MyComponent({ clip }) {
  121. const frame = useCurrentFrame();
  122. const transition = useTransition(clip, frame);
  123. return (
  124. <div style={{
  125. opacity: transition.opacity,
  126. transform: transition.transform,
  127. }}>
  128. Content
  129. </div>
  130. );
  131. }`}</Code>
  132. <h3 className="text-lg font-semibold mt-8 mb-4">ClipWrapper</h3>
  133. <p className="text-sm text-muted-foreground mb-4">
  134. Automatically apply transitions to clip content:
  135. </p>
  136. <Code lang="tsx">{`import { ClipWrapper } from '@json-render/remotion';
  137. function MyClip({ clip }) {
  138. return (
  139. <ClipWrapper clip={clip}>
  140. <div>My content with automatic transitions</div>
  141. </ClipWrapper>
  142. );
  143. }`}</Code>
  144. <h2 className="text-xl font-semibold mt-12 mb-4">Types</h2>
  145. <h3 className="text-lg font-semibold mt-8 mb-4">TimelineSpec</h3>
  146. <Code lang="typescript">{`interface TimelineSpec {
  147. composition: {
  148. id: string;
  149. fps: number;
  150. width: number;
  151. height: number;
  152. durationInFrames: number;
  153. };
  154. tracks: Track[];
  155. clips: Clip[];
  156. audio: {
  157. tracks: AudioTrack[];
  158. };
  159. }`}</Code>
  160. <h3 className="text-lg font-semibold mt-8 mb-4">Clip</h3>
  161. <Code lang="typescript">{`interface Clip {
  162. id: string;
  163. trackId: string;
  164. component: string;
  165. props: Record<string, unknown>;
  166. from: number;
  167. durationInFrames: number;
  168. transitionIn?: {
  169. type: string;
  170. durationInFrames: number;
  171. };
  172. transitionOut?: {
  173. type: string;
  174. durationInFrames: number;
  175. };
  176. }`}</Code>
  177. <h3 className="text-lg font-semibold mt-8 mb-4">TransitionStyles</h3>
  178. <Code lang="typescript">{`interface TransitionStyles {
  179. opacity: number;
  180. transform: string;
  181. }`}</Code>
  182. <h3 className="text-lg font-semibold mt-8 mb-4">ComponentRegistry</h3>
  183. <Code lang="typescript">{`type ClipComponent = React.ComponentType<{ clip: Clip }>;
  184. type ComponentRegistry = Record<string, ClipComponent>;`}</Code>
  185. <h2 className="text-xl font-semibold mt-12 mb-4">Transitions</h2>
  186. <p className="text-sm text-muted-foreground mb-4">
  187. Available transition types:
  188. </p>
  189. <ul className="list-disc list-inside text-sm text-muted-foreground space-y-1 mb-4">
  190. <li>
  191. <code className="text-foreground">fade</code> - Opacity fade in/out
  192. </li>
  193. <li>
  194. <code className="text-foreground">slideLeft</code> - Slide from right
  195. </li>
  196. <li>
  197. <code className="text-foreground">slideRight</code> - Slide from left
  198. </li>
  199. <li>
  200. <code className="text-foreground">slideUp</code> - Slide from bottom
  201. </li>
  202. <li>
  203. <code className="text-foreground">slideDown</code> - Slide from top
  204. </li>
  205. <li>
  206. <code className="text-foreground">zoom</code> - Scale zoom in/out
  207. </li>
  208. <li>
  209. <code className="text-foreground">wipe</code> - Horizontal wipe
  210. </li>
  211. </ul>
  212. </article>
  213. );
  214. }