page.mdx 5.1 KB

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