Skip to content

🎥 Make videos programmatically with React

update "what is remotion" component

Jonny Burger8e502f468ddf
diff --git a/packages/example/src/Compose/Compose.tsx b/packages/example/src/Compose/WhatIsRemotion.tsx
similarity index 88%
rename from packages/example/src/Compose/Compose.tsx
rename to packages/example/src/Compose/WhatIsRemotion.tsx
index 1a0726da17..3087b9ae3a 100644
--- a/packages/example/src/Compose/Compose.tsx
+++ b/packages/example/src/Compose/WhatIsRemotion.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import {
AbsoluteFill,
+ CalculateMetadataFunction,
Easing,
interpolate,
measureSpring,
@@ -11,6 +12,7 @@ import {
useCurrentFrame,
useVideoConfig,
} from 'remotion';
+import {z} from 'zod';
import {ExtrudeDiv} from '../3DContext/Div3D';
import {
RotateY,
@@ -183,7 +185,27 @@ const CaptionLayers: React.FC<{
);
};
-export const Compose = () => {
+export const whatIsRemotionSchema = z.object({
+ fade: z.boolean(),
+ whiteBackground: z.boolean(),
+ reel: z.boolean(),
+});
+
+export const whatIsRemotionCalculateMetadata: CalculateMetadataFunction<
+ z.infer<typeof whatIsRemotionSchema>
+> = ({props}) => {
+ return {
+ height: props.reel ? 1920 : 1080,
+ durationInFrames: props.reel ? 276 : 273,
+ props,
+ };
+};
+
+export const WhatIsRemotion = ({
+ fade,
+ whiteBackground,
+ reel,
+}: z.infer<typeof whatIsRemotionSchema>) => {
const frame = useCurrentFrame();
const {fps} = useVideoConfig();
const bRollEnter = spring({
@@ -259,12 +281,17 @@ export const Compose = () => {
const outActual = getActualLayerWidth(1 - outAnimation);
return (
- <AbsoluteFill className="flex justify-center items-center">
- <Scale factor={1.1}>
+ <AbsoluteFill
+ style={{
+ backgroundColor: whiteBackground ? 'white' : undefined,
+ }}
+ className="flex justify-center items-center"
+ >
+ <Scale factor={reel ? 1.3 : 1.1}>
<AbsoluteFill
style={{
maskImage:
- frame > 100
+ frame > 100 && fade
? 'linear-gradient( -98deg, transparent 5%, red 15%, red 80%, transparent 90%)'
: 'none',
}}
@@ -284,15 +311,16 @@ export const Compose = () => {
</AbsoluteFill>
<AbsoluteFill
style={{
- maskImage:
- 'linear-gradient( -7deg, transparent 6%, red 15%, red 84%, transparent 94%)',
+ maskImage: fade
+ ? 'linear-gradient( -7deg, transparent 6%, red 15%, red 84%, transparent 94%)'
+ : 'none',
}}
>
<TranslateY
px={interpolate(
bRollEnter + bRollExit,
[0, 1, 2],
- [1500, 0, -1500],
+ [1900, 0, -1900],
)}
>
<VideoLayers
@@ -307,7 +335,7 @@ export const Compose = () => {
<AbsoluteFill
style={{
maskImage:
- frame > 100
+ frame > 100 && fade
? 'linear-gradient( -98deg, transparent 10%, red 18%, red 80%, transparent 90%)'
: 'none',
}}
@@ -329,7 +357,9 @@ export const Compose = () => {
)}
<AbsoluteFill
style={{
- maskImage: 'linear-gradient(to bottom, transparent , black 10%)',
+ maskImage: fade
+ ? 'linear-gradient(to bottom, transparent , black 10%)'
+ : undefined,
}}
>
<TranslateX px={secondX}>
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index 2ad3d2e6c7..684a20a31b 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -119,7 +119,11 @@ import {ThreeDContext} from './3DContext';
import {ThreeDEngine} from './3DEngine';
import {ThreeDSvgContent} from './3DSvgContent';
import {AnimatedImages} from './AnimatedImage/Avif';
-import {Compose} from './Compose/Compose';
+import {
+ WhatIsRemotion,
+ whatIsRemotionCalculateMetadata,
+ whatIsRemotionSchema,
+} from './Compose/WhatIsRemotion';
import {Empty} from './Empty';
import {ParseAndDownloadMedia} from './ParseAndDownloadMedia';
import {SmoothTextTransition} from './SmoothTextTransition';
@@ -1150,7 +1154,6 @@ export const Index: React.FC = () => {
durationInFrames={150}
/>
</Folder>
-
<Folder name="shapes">
<Composition
id="circle-test"
@@ -1306,7 +1309,7 @@ export const Index: React.FC = () => {
}}
/>
{/**
- // @ts-expect-error intentional */}
+ // @ts-expect-error intentional */}
<Composition
id="impossible-to-save"
component={SchemaTest}
@@ -1364,29 +1367,28 @@ export const Index: React.FC = () => {
durationInFrames={120}
/>
{/**
- *
- *
- * disabled for react 19
- <Folder name="Skia">
- <Composition
- id="skia-shader"
- component={RuntimeShaderDemo}
- fps={30}
- height={1080}
- width={1080}
- durationInFrames={120}
- />
- <Composition
- id="skia-zoomblur"
- component={RuntimeShaderZoomBlur}
- fps={30}
- height={1080}
- width={1080}
- durationInFrames={120}
- />
- </Folder>
- */}
-
+ *
+ *
+ * disabled for react 19
+ <Folder name="Skia">
+ <Composition
+ id="skia-shader"
+ component={RuntimeShaderDemo}
+ fps={30}
+ height={1080}
+ width={1080}
+ durationInFrames={120}
+ />
+ <Composition
+ id="skia-zoomblur"
+ component={RuntimeShaderZoomBlur}
+ fps={30}
+ height={1080}
+ width={1080}
+ durationInFrames={120}
+ />
+ </Folder>
+ */}
<Folder name="studio-apis">
<Composition
id="save-default-props"
@@ -1520,12 +1522,14 @@ export const Index: React.FC = () => {
durationInFrames={1000}
/>
<Composition
- id="3DCompose"
- component={Compose}
+ id="WhatIsRemotion"
+ component={WhatIsRemotion}
width={1080}
- height={1080}
fps={30}
durationInFrames={273}
+ schema={whatIsRemotionSchema}
+ defaultProps={{fade: false, whiteBackground: true, reel: true}}
+ calculateMetadata={whatIsRemotionCalculateMetadata}
/>
<Composition
id="3DContext"