page.mdx 5.0 KB

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