Skip to content

🎥 Make videos programmatically with React

`@remotion/jonnys-videos`: Separate video projects

JonnyBurgerbac1c3a3d602
diff --git a/packages/jonnys-videos/src/Root.tsx b/packages/jonnys-videos/src/Root.tsx
index 7babd8d968..cdaedfa7c5 100644
--- a/packages/jonnys-videos/src/Root.tsx
+++ b/packages/jonnys-videos/src/Root.tsx
@@ -1,10 +1,16 @@
import {Folder} from 'remotion';
import {DiscoLightShowRoot} from './disco-light-show/Root';
+import {HowCanRemotionBeFreeRoot} from './how-can-remotion-be-free/Root';
export const RemotionRoot: React.FC = () => {
return (
- <Folder name="DiscoLightShow">
- <DiscoLightShowRoot />
- </Folder>
+ <>
+ <Folder name="DiscoLightShow">
+ <DiscoLightShowRoot />
+ </Folder>
+ <Folder name="HowCanRemotionBeFree">
+ <HowCanRemotionBeFreeRoot />
+ </Folder>
+ </>
);
};
diff --git a/packages/jonnys-videos/src/components/AnimatedCaptions.tsx b/packages/jonnys-videos/src/components/AnimatedCaptions.tsx
new file mode 100644
index 0000000000..a37b2ddfad
--- /dev/null
+++ b/packages/jonnys-videos/src/components/AnimatedCaptions.tsx
@@ -0,0 +1,150 @@
+import type {Caption, TikTokPage} from '@remotion/captions';
+import {Audio} from '@remotion/media';
+import React, {useCallback, useEffect, useMemo, useState} from 'react';
+import {
+ AbsoluteFill,
+ Sequence,
+ useCurrentFrame,
+ useDelayRender,
+ useVideoConfig,
+} from 'remotion';
+import {createSentenceAwareCaptionPages} from './paginate-captions';
+
+export const CAPTIONS_HEIGHT = 360;
+
+type AnimatedCaptionsProps = {
+ captionsSrc: string;
+ voiceoverSrc: string | null;
+};
+
+const SWITCH_CAPTIONS_EVERY_MS = 1100;
+const HIGHLIGHT_COLOR = '#ff3b1f';
+
+const CaptionPage: React.FC<{page: TikTokPage}> = ({page}) => {
+ const frame = useCurrentFrame();
+ const {fps} = useVideoConfig();
+ const absoluteTimeMs = page.startMs + (frame / fps) * 1000;
+
+ return (
+ <AbsoluteFill
+ style={{
+ alignItems: 'center',
+ justifyContent: 'center',
+ padding: '42px 64px 48px',
+ pointerEvents: 'none',
+ }}
+ >
+ <div
+ style={{
+ textAlign: 'center',
+ fontFamily: 'Arial Black, Arial, sans-serif',
+ fontSize: 76,
+ fontWeight: 900,
+ letterSpacing: -3.5,
+ lineHeight: 1.05,
+ textWrap: 'balance',
+ whiteSpace: 'pre-wrap',
+ filter:
+ 'drop-shadow(0 8px 0 rgba(0, 0, 0, 0.82)) drop-shadow(0 16px 24px rgba(0, 0, 0, 0.55))',
+ }}
+ >
+ {page.tokens.map((token, tokenIndex) => {
+ const isActive =
+ token.fromMs <= absoluteTimeMs && token.toMs > absoluteTimeMs;
+ return (
+ <span
+ key={`${token.fromMs}-${tokenIndex}`}
+ style={{
+ color: isActive ? HIGHLIGHT_COLOR : '#ffffff',
+ display: 'inline-block',
+ marginLeft: tokenIndex === 0 ? 0 : 26,
+ WebkitTextStroke: isActive
+ ? '3px rgba(38, 4, 0, 0.95)'
+ : '2px rgba(0, 0, 0, 0.85)',
+ }}
+ >
+ {token.text.trimStart()}
+ </span>
+ );
+ })}
+ </div>
+ </AbsoluteFill>
+ );
+};
+
+export const AnimatedCaptions: React.FC<AnimatedCaptionsProps> = ({
+ captionsSrc,
+ voiceoverSrc,
+}) => {
+ const [captions, setCaptions] = useState<Caption[] | null>(null);
+ const {delayRender, continueRender, cancelRender} = useDelayRender();
+ const [handle] = useState(() => delayRender('Loading ElevenLabs captions'));
+ const {fps} = useVideoConfig();
+
+ const loadCaptions = useCallback(async () => {
+ try {
+ const response = await fetch(captionsSrc);
+ if (!response.ok) {
+ throw new Error(`Could not load captions (${response.status})`);
+ }
+
+ setCaptions((await response.json()) as Caption[]);
+ continueRender(handle);
+ } catch (error) {
+ cancelRender(error);
+ }
+ }, [cancelRender, captionsSrc, continueRender, handle]);
+
+ useEffect(() => {
+ loadCaptions();
+ }, [loadCaptions]);
+
+ const pages = useMemo(() => {
+ if (!captions) {
+ return [];
+ }
+
+ return createSentenceAwareCaptionPages({
+ captions,
+ combineTokensWithinMilliseconds: SWITCH_CAPTIONS_EVERY_MS,
+ });
+ }, [captions]);
+
+ if (!captions) {
+ return null;
+ }
+
+ return (
+ <AbsoluteFill>
+ {voiceoverSrc ? (
+ <Audio src={voiceoverSrc} hidden showInTimeline={false} />
+ ) : null}
+ {pages.map((page, index) => {
+ const nextPage = pages[index + 1];
+ const startFrame = Math.round((page.startMs / 1000) * fps);
+ const naturalEndFrame = Math.ceil(
+ ((page.startMs + page.durationMs) / 1000) * fps,
+ );
+ const endFrame = nextPage
+ ? Math.min(
+ Math.round((nextPage.startMs / 1000) * fps),
+ naturalEndFrame,
+ )
+ : naturalEndFrame;
+ const durationInFrames = Math.max(1, endFrame - startFrame);
+
+ return (
+ <Sequence
+ key={`${page.startMs}-${index}`}
+ from={startFrame}
+ durationInFrames={durationInFrames}
+ premountFor={fps}
+ showInTimeline={false}
+ >
+ <CaptionPage page={page} />
+ </Sequence>
+ );
+ })}
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/jonnys-videos/src/disco-light-show/paginate-captions.ts b/packages/jonnys-videos/src/components/paginate-captions.ts
similarity index 100%
rename from packages/jonnys-videos/src/disco-light-show/paginate-captions.ts
rename to packages/jonnys-videos/src/components/paginate-captions.ts
diff --git a/packages/jonnys-videos/src/disco-light-show/AnimatedCaptions.tsx b/packages/jonnys-videos/src/disco-light-show/AnimatedCaptions.tsx
index 2332502945..ea90f2d43b 100644
--- a/packages/jonnys-videos/src/disco-light-show/AnimatedCaptions.tsx
+++ b/packages/jonnys-videos/src/disco-light-show/AnimatedCaptions.tsx
@@ -1,154 +1,19 @@
-import type {Caption, TikTokPage} from '@remotion/captions';
-import {Audio} from '@remotion/media';
-import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {
- AbsoluteFill,
- Sequence,
- useCurrentFrame,
- useDelayRender,
- useVideoConfig,
-} from 'remotion';
+ AnimatedCaptions as SharedAnimatedCaptions,
+ CAPTIONS_HEIGHT,
+} from '../components/AnimatedCaptions';
import {asset} from './assets';
-import {createSentenceAwareCaptionPages} from './paginate-captions';
export const VOICEOVER_FILE = 'text-behind-video-2.wav';
export const CAPTIONS_FILE = 'voiceover-captions.json';
export const CAPTIONS_DURATION_IN_FRAMES = 1816;
-export const CAPTIONS_HEIGHT = 360;
-
-type AnimatedCaptionsProps = {
- captionsFile?: string;
- voiceoverFile?: string | null;
-};
-
-const SWITCH_CAPTIONS_EVERY_MS = 1100;
-const HIGHLIGHT_COLOR = '#ff3b1f';
-
-const CaptionPage: React.FC<{page: TikTokPage}> = ({page}) => {
- const frame = useCurrentFrame();
- const {fps} = useVideoConfig();
- const absoluteTimeMs = page.startMs + (frame / fps) * 1000;
-
- return (
- <AbsoluteFill
- style={{
- alignItems: 'center',
- justifyContent: 'center',
- padding: '42px 64px 48px',
- pointerEvents: 'none',
- }}
- >
- <div
- style={{
- textAlign: 'center',
- fontFamily: 'Arial Black, Arial, sans-serif',
- fontSize: 76,
- fontWeight: 900,
- letterSpacing: -3.5,
- lineHeight: 1.05,
- textWrap: 'balance',
- whiteSpace: 'pre-wrap',
- filter:
- 'drop-shadow(0 8px 0 rgba(0, 0, 0, 0.82)) drop-shadow(0 16px 24px rgba(0, 0, 0, 0.55))',
- }}
- >
- {page.tokens.map((token, tokenIndex) => {
- const isActive =
- token.fromMs <= absoluteTimeMs && token.toMs > absoluteTimeMs;
- return (
- <span
- key={`${token.fromMs}-${tokenIndex}`}
- style={{
- color: isActive ? HIGHLIGHT_COLOR : '#ffffff',
- display: 'inline-block',
- marginLeft: tokenIndex === 0 ? 0 : 26,
- WebkitTextStroke: isActive
- ? '3px rgba(38, 4, 0, 0.95)'
- : '2px rgba(0, 0, 0, 0.85)',
- }}
- >
- {token.text.trimStart()}
- </span>
- );
- })}
- </div>
- </AbsoluteFill>
- );
-};
-
-export const AnimatedCaptions: React.FC<AnimatedCaptionsProps> = ({
- captionsFile = CAPTIONS_FILE,
- voiceoverFile = VOICEOVER_FILE,
-}) => {
- const [captions, setCaptions] = useState<Caption[] | null>(null);
- const {delayRender, continueRender, cancelRender} = useDelayRender();
- const [handle] = useState(() => delayRender('Loading ElevenLabs captions'));
- const {fps} = useVideoConfig();
-
- const loadCaptions = useCallback(async () => {
- try {
- const response = await fetch(asset(captionsFile));
- if (!response.ok) {
- throw new Error(`Could not load captions (${response.status})`);
- }
-
- setCaptions((await response.json()) as Caption[]);
- continueRender(handle);
- } catch (error) {
- cancelRender(error);
- }
- }, [cancelRender, captionsFile, continueRender, handle]);
-
- useEffect(() => {
- loadCaptions();
- }, [loadCaptions]);
-
- const pages = useMemo(() => {
- if (!captions) {
- return [];
- }
-
- return createSentenceAwareCaptionPages({
- captions,
- combineTokensWithinMilliseconds: SWITCH_CAPTIONS_EVERY_MS,
- });
- }, [captions]);
-
- if (!captions) {
- return null;
- }
+export {CAPTIONS_HEIGHT};
+export const AnimatedCaptions: React.FC = () => {
return (
- <AbsoluteFill>
- {voiceoverFile ? (
- <Audio src={asset(voiceoverFile)} hidden showInTimeline={false} />
- ) : null}
- {pages.map((page, index) => {
- const nextPage = pages[index + 1];
- const startFrame = Math.round((page.startMs / 1000) * fps);
- const naturalEndFrame = Math.ceil(
- ((page.startMs + page.durationMs) / 1000) * fps,
- );
- const endFrame = nextPage
- ? Math.min(
- Math.round((nextPage.startMs / 1000) * fps),
- naturalEndFrame,
- )
- : naturalEndFrame;
- const durationInFrames = Math.max(1, endFrame - startFrame);
-
- return (
- <Sequence
- key={`${page.startMs}-${index}`}
- from={startFrame}
- durationInFrames={durationInFrames}
- premountFor={fps}
- showInTimeline={false}
- >
- <CaptionPage page={page} />
- </Sequence>
- );
- })}
- </AbsoluteFill>
+ <SharedAnimatedCaptions
+ captionsSrc={asset(CAPTIONS_FILE)}
+ voiceoverSrc={asset(VOICEOVER_FILE)}
+ />
);
};
diff --git a/packages/jonnys-videos/src/disco-light-show/AnimatedCaptionsBigWords.tsx b/packages/jonnys-videos/src/disco-light-show/AnimatedCaptionsBigWords.tsx
index dae7ec76f6..c707cfec03 100644
--- a/packages/jonnys-videos/src/disco-light-show/AnimatedCaptionsBigWords.tsx
+++ b/packages/jonnys-videos/src/disco-light-show/AnimatedCaptionsBigWords.tsx
@@ -11,8 +11,8 @@ import {
useDelayRender,
useVideoConfig,
} from 'remotion';
+import {createSentenceAwareCaptionPages} from '../components/paginate-captions';
import {asset} from './assets';
-import {createSentenceAwareCaptionPages} from './paginate-captions';
export const BIG_WORD_CAPTIONS_DURATION_IN_FRAMES = 1816;
diff --git a/packages/jonnys-videos/src/disco-light-show/Root.tsx b/packages/jonnys-videos/src/disco-light-show/Root.tsx
index 2e512b3920..16b2188d2b 100644
--- a/packages/jonnys-videos/src/disco-light-show/Root.tsx
+++ b/packages/jonnys-videos/src/disco-light-show/Root.tsx
@@ -1,4 +1,4 @@
-import {Composition, Folder} from 'remotion';
+import {Composition} from 'remotion';
import {
AnimatedCaptions,
CAPTIONS_DURATION_IN_FRAMES,
@@ -24,29 +24,16 @@ import {DiscoBallBg} from './DiscoBallBg';
import {DragIn} from './DragIn';
import {DragInDemo} from './DragInDemo';
import {EffectShow} from './EffectShow';
-import {
- FIRST_CUSTOMER_CHART_DURATION_IN_FRAMES,
- FirstCustomerChart,
-} from './FirstCustomerChart';
import {Fork} from './Fork';
import {ForkDrop} from './ForkDrop';
-import {FreeMaster} from './FreeMaster';
import {HuggingFace} from './HuggingFace';
import {MasterWithEffect} from './MasterWithEffect';
import {Mediabunny} from './Mediabunny';
import {OneShot} from './OneShot';
-import {
- PREMIUM_VERSION_DURATION_IN_FRAMES,
- PremiumVersion,
-} from './PremiumVersion';
import {Separate} from './Separate';
import {Setup} from './Setup';
import {TextBehindVideoSeriesFirst20s} from './TextBehindVideoSeriesFirst20s';
import {TextBehindVideoStack} from './TextBehindVideoStack';
-import {
- UNRULY_OUTCOME_DURATION_IN_FRAMES,
- UnrulyOutcome,
-} from './UnrulyOutcome';
import {VibeCoded} from './VibeCoded';
export const DiscoLightShowRoot: React.FC = () => {
@@ -263,40 +250,6 @@ export const DiscoLightShowRoot: React.FC = () => {
width={1080}
height={1920}
/>
- <Folder name="HowIsRemotionFree">
- <Composition
- id="FirstCustomerChart"
- component={FirstCustomerChart}
- durationInFrames={FIRST_CUSTOMER_CHART_DURATION_IN_FRAMES}
- fps={30}
- width={1080}
- height={1920}
- />
- <Composition
- id="PremiumVersion"
- component={PremiumVersion}
- durationInFrames={PREMIUM_VERSION_DURATION_IN_FRAMES}
- fps={30}
- width={1080}
- height={1920}
- />
- <Composition
- id="UnrulyOutcome"
- component={UnrulyOutcome}
- durationInFrames={UNRULY_OUTCOME_DURATION_IN_FRAMES}
- fps={30}
- width={1080}
- height={1920}
- />
- <Composition
- id="FreeMaster"
- component={FreeMaster}
- durationInFrames={1800}
- fps={30}
- width={1080}
- height={1920}
- />
- </Folder>
</>
);
};
diff --git a/packages/jonnys-videos/src/disco-light-show/FirstCustomerChart.tsx b/packages/jonnys-videos/src/how-can-remotion-be-free/FirstCustomerChart.tsx
similarity index 100%
rename from packages/jonnys-videos/src/disco-light-show/FirstCustomerChart.tsx
rename to packages/jonnys-videos/src/how-can-remotion-be-free/FirstCustomerChart.tsx
diff --git a/packages/jonnys-videos/src/disco-light-show/FreeMaster.tsx b/packages/jonnys-videos/src/how-can-remotion-be-free/HowCanRemotionBeFree.tsx
similarity index 80%
rename from packages/jonnys-videos/src/disco-light-show/FreeMaster.tsx
rename to packages/jonnys-videos/src/how-can-remotion-be-free/HowCanRemotionBeFree.tsx
index a2a9dde47b..19ed06fc22 100644
--- a/packages/jonnys-videos/src/disco-light-show/FreeMaster.tsx
+++ b/packages/jonnys-videos/src/how-can-remotion-be-free/HowCanRemotionBeFree.tsx
@@ -1,7 +1,10 @@
import {Audio} from '@remotion/media';
import React from 'react';
import {Sequence, Solid} from 'remotion';
-import {AnimatedCaptions, CAPTIONS_HEIGHT} from './AnimatedCaptions';
+import {
+ AnimatedCaptions,
+ CAPTIONS_HEIGHT,
+} from '../components/AnimatedCaptions';
import {asset} from './assets';
import {
FIRST_CUSTOMER_CHART_DURATION_IN_FRAMES,
@@ -17,18 +20,20 @@ import {
} from './UnrulyOutcome';
import {ZURICH_PHOTO_DURATION_IN_FRAMES, ZurichPhoto} from './ZurichPhoto';
-const FREE_MASTER_AUDIO_FILE =
- 'ElevenLabs_2026-08-23T17_39_27_Derek - Fun & Energetic _pvc_sp115_s50_sb75_se0_b_m2.mp3';
-const FREE_MASTER_CAPTIONS_FILE = 'free-master-captions.json';
+const HOW_CAN_REMOTION_BE_FREE_AUDIO_FILE = 'voiceover.mp3';
+const HOW_CAN_REMOTION_BE_FREE_CAPTIONS_FILE = 'captions.json';
const PREMIUM_VERSION_START_FRAME = 100;
const UNRULY_OUTCOME_START_FRAME = 148;
const FIRST_CUSTOMER_CHART_START_FRAME = 645;
const SWITZERLAND_SCENE_START_FRAME = 816;
-export const FreeMaster: React.FC = () => {
+export const HowCanRemotionBeFree: React.FC = () => {
return (
<>
- <Audio src={asset(FREE_MASTER_AUDIO_FILE)} durationInFrames={1674.71} />
+ <Audio
+ src={asset(HOW_CAN_REMOTION_BE_FREE_AUDIO_FILE)}
+ durationInFrames={1674.71}
+ />
<Solid
width={1080}
height={1920}
@@ -79,8 +84,8 @@ export const FreeMaster: React.FC = () => {
}}
>
<AnimatedCaptions
- captionsFile={FREE_MASTER_CAPTIONS_FILE}
- voiceoverFile={null}
+ captionsSrc={asset(HOW_CAN_REMOTION_BE_FREE_CAPTIONS_FILE)}
+ voiceoverSrc={null}
/>
</Sequence>
</>
diff --git a/packages/jonnys-videos/src/disco-light-show/PremiumVersion.tsx b/packages/jonnys-videos/src/how-can-remotion-be-free/PremiumVersion.tsx
similarity index 100%
rename from packages/jonnys-videos/src/disco-light-show/PremiumVersion.tsx
rename to packages/jonnys-videos/src/how-can-remotion-be-free/PremiumVersion.tsx
diff --git a/packages/jonnys-videos/src/how-can-remotion-be-free/Root.tsx b/packages/jonnys-videos/src/how-can-remotion-be-free/Root.tsx
new file mode 100644
index 0000000000..8ad3fe321e
--- /dev/null
+++ b/packages/jonnys-videos/src/how-can-remotion-be-free/Root.tsx
@@ -0,0 +1,64 @@
+import {Composition, Folder} from 'remotion';
+import {
+ FIRST_CUSTOMER_CHART_DURATION_IN_FRAMES,
+ FirstCustomerChart,
+} from './FirstCustomerChart';
+import {HowCanRemotionBeFree} from './HowCanRemotionBeFree';
+import {
+ PREMIUM_VERSION_DURATION_IN_FRAMES,
+ PremiumVersion,
+} from './PremiumVersion';
+import {
+ UNRULY_OUTCOME_DURATION_IN_FRAMES,
+ UnrulyOutcome,
+} from './UnrulyOutcome';
+import {ZURICH_PHOTO_DURATION_IN_FRAMES, ZurichPhoto} from './ZurichPhoto';
+
+export const HowCanRemotionBeFreeRoot: React.FC = () => {
+ return (
+ <>
+ <Composition
+ id="HowCanRemotionBeFree"
+ component={HowCanRemotionBeFree}
+ durationInFrames={1800}
+ fps={30}
+ width={1080}
+ height={1920}
+ />
+ <Folder name="Scenes">
+ <Composition
+ id="FirstCustomerChart"
+ component={FirstCustomerChart}
+ durationInFrames={FIRST_CUSTOMER_CHART_DURATION_IN_FRAMES}
+ fps={30}
+ width={1080}
+ height={1920}
+ />
+ <Composition
+ id="PremiumVersion"
+ component={PremiumVersion}
+ durationInFrames={PREMIUM_VERSION_DURATION_IN_FRAMES}
+ fps={30}
+ width={1080}
+ height={1920}
+ />
+ <Composition
+ id="UnrulyOutcome"
+ component={UnrulyOutcome}
+ durationInFrames={UNRULY_OUTCOME_DURATION_IN_FRAMES}
+ fps={30}
+ width={1080}
+ height={1920}
+ />
+ <Composition
+ id="ZurichPhoto"
+ component={ZurichPhoto}
+ durationInFrames={ZURICH_PHOTO_DURATION_IN_FRAMES}
+ fps={30}
+ width={1080}
+ height={1920}
+ />
+ </Folder>
+ </>
+ );
+};
diff --git a/packages/jonnys-videos/src/disco-light-show/UnrulyOutcome.tsx b/packages/jonnys-videos/src/how-can-remotion-be-free/UnrulyOutcome.tsx
similarity index 100%
rename from packages/jonnys-videos/src/disco-light-show/UnrulyOutcome.tsx
rename to packages/jonnys-videos/src/how-can-remotion-be-free/UnrulyOutcome.tsx
diff --git a/packages/jonnys-videos/src/disco-light-show/ZurichPhoto.tsx b/packages/jonnys-videos/src/how-can-remotion-be-free/ZurichPhoto.tsx
similarity index 100%
rename from packages/jonnys-videos/src/disco-light-show/ZurichPhoto.tsx
rename to packages/jonnys-videos/src/how-can-remotion-be-free/ZurichPhoto.tsx
diff --git a/packages/jonnys-videos/src/how-can-remotion-be-free/assets.ts b/packages/jonnys-videos/src/how-can-remotion-be-free/assets.ts
new file mode 100644
index 0000000000..5ccc48ce08
--- /dev/null
+++ b/packages/jonnys-videos/src/how-can-remotion-be-free/assets.ts
@@ -0,0 +1,6 @@
+const ASSET_BASE_URL =
+ 'https://remotion.media/jonnys-videos/how-can-remotion-be-free/';
+
+export const asset = (filename: string) => {
+ return `${ASSET_BASE_URL}${encodeURIComponent(filename)}`;
+};