Skip to content

🎥 Make videos programmatically with React

Add four-person grid animation

JonnyBurger40a8132f3a47
diff --git a/packages/jonnys-videos/.gitignore b/packages/jonnys-videos/.gitignore
new file mode 100644
index 0000000000..5fa8610e5d
--- /dev/null
+++ b/packages/jonnys-videos/.gitignore
@@ -0,0 +1,6 @@
+public/how-can-remotion-be-free/voiceover-2.mp3
+public/how-can-remotion-be-free/captions-2.json
+public/image.png
+public/image-1.png
+public/image-2.png
+public/image-3.png
diff --git a/packages/jonnys-videos/src/Composition4People.tsx b/packages/jonnys-videos/src/Composition4People.tsx
new file mode 100644
index 0000000000..7d41486b47
--- /dev/null
+++ b/packages/jonnys-videos/src/Composition4People.tsx
@@ -0,0 +1,89 @@
+import React from 'react';
+import {
+ AbsoluteFill,
+ CanvasImage,
+ Easing,
+ interpolate,
+ useCurrentFrame,
+ useVideoConfig,
+} from 'remotion';
+
+export const Composition4People: React.FC = () => {
+ const frame = useCurrentFrame();
+ const {fps} = useVideoConfig();
+
+ return (
+ <AbsoluteFill
+ name="People grid"
+ style={{
+ backgroundColor: 'black',
+ display: 'grid',
+ gridTemplateColumns: '1fr 1fr',
+ gridTemplateRows: '1fr 1fr',
+ gap: 24,
+ padding: 24,
+ }}
+ >
+ <CanvasImage
+ name="Top left person"
+ src="https://remotion.media/jonnys-videos/four-people/person-1.png"
+ style={{
+ width: '100%',
+ height: '100%',
+ objectFit: 'cover',
+ scale: interpolate(frame, [0, 2 * fps], [0, 1], {
+ easing: Easing.bezier(0.16, 1, 0.3, 1),
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ output: 'perceptual-scale',
+ }),
+ }}
+ />
+ <CanvasImage
+ name="Top right person"
+ src="https://remotion.media/jonnys-videos/four-people/person-4.png"
+ style={{
+ width: '100%',
+ height: '100%',
+ objectFit: 'cover',
+ scale: interpolate(frame, [0, 2 * fps], [0, 1], {
+ easing: Easing.bezier(0.16, 1, 0.3, 1),
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ output: 'perceptual-scale',
+ }),
+ }}
+ />
+ <CanvasImage
+ name="Bottom left person"
+ src="https://remotion.media/jonnys-videos/four-people/person-2.png"
+ style={{
+ width: '100%',
+ height: '100%',
+ objectFit: 'cover',
+ scale: interpolate(frame, [0, 2 * fps], [0, 1], {
+ easing: Easing.bezier(0.16, 1, 0.3, 1),
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ output: 'perceptual-scale',
+ }),
+ }}
+ />
+ <CanvasImage
+ name="Bottom right person"
+ src="https://remotion.media/jonnys-videos/four-people/person-3.png"
+ style={{
+ width: '100%',
+ height: '100%',
+ objectFit: 'cover',
+ scale: interpolate(frame, [0, 2 * fps], [0, 1], {
+ easing: Easing.bezier(0.16, 1, 0.3, 1),
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ output: 'perceptual-scale',
+ }),
+ }}
+ />
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/jonnys-videos/src/Root.tsx b/packages/jonnys-videos/src/Root.tsx
index 85b1200858..037275bc85 100644
--- a/packages/jonnys-videos/src/Root.tsx
+++ b/packages/jonnys-videos/src/Root.tsx
@@ -1,4 +1,5 @@
import {Composition, Folder} from 'remotion';
+import {Composition4People} from './Composition4People';
import {
AnimatedCaptions,
CAPTIONS_DURATION_IN_FRAMES,
@@ -64,7 +65,7 @@ export const RemotionRoot: React.FC = () => {
<Composition
id="MasterWithEffect"
component={MasterWithEffect}
- durationInFrames={1800}
+ durationInFrames={1802}
fps={30}
width={1080}
height={1920}
@@ -314,6 +315,14 @@ export const RemotionRoot: React.FC = () => {
width={1080}
height={1920}
/>
+ <Composition
+ id="4People"
+ component={Composition4People}
+ durationInFrames={1800}
+ fps={30}
+ width={1080}
+ height={1920}
+ />
</Folder>
</Folder>
</>