🎥 Make videos programmatically with React
Refine Studio coding handoff layout
Jonny Burgerdf4d1942339d
diff --git a/packages/brand/src/Root.tsx b/packages/brand/src/Root.tsxindex b7163e1329..f220c2bbbb 100644--- a/packages/brand/src/Root.tsx+++ b/packages/brand/src/Root.tsx@@ -122,7 +122,7 @@ import {Skills2Router} from './Skills2Router';import {Skills2TableBang} from './Skills2TableBang';import {Skills2TableBangComp} from './Skills2TableBangComp';import {SvgLogoCompositions} from './SvgLogos';-import {Codex} from './video-elements/Codex';+import {Codex, codexSchema} from './video-elements/Codex';import {FlyingCardsLeft,flyingCardsLeftSchema,@@ -417,16 +417,22 @@ export const RemotionRoot: React.FC = () => {component={Codex}durationInFrames={1}fps={30}- width={1193}- height={1040}+ width={1081}+ height={928}+ schema={codexSchema}+ defaultProps={{height: 928, width: 1081}}+ calculateMetadata={({props}) => ({+ height: props.height,+ width: props.width,+ })}/><Compositionid="TextEditorUI"component={TextEditor}durationInFrames={1}fps={30}- width={1399}- height={1362}+ width={1287}+ height={1250}schema={textEditorSchema}defaultProps={{code: `import {Video} from '@remotion/media';@@ -469,9 +475,9 @@ export const Scene11: React.FC<{platform: EndCardPlatform}> = ({platform}) => {};`,fileName: 'Scene11.tsx',- height: 1362,+ height: 1250,highlightedLines: '39',- width: 1399,+ width: 1287,}}calculateMetadata={({props}) => ({height: props.height, width: props.width})}/>diff --git a/packages/brand/src/video-elements/Codex.tsx b/packages/brand/src/video-elements/Codex.tsxindex 5c76199774..31753355f1 100644--- a/packages/brand/src/video-elements/Codex.tsx+++ b/packages/brand/src/video-elements/Codex.tsx@@ -1,5 +1,6 @@import React from 'react';import {AbsoluteFill, Img, Interactive, staticFile} from 'remotion';+import {z} from 'zod';import {AlertCircleIcon,AtIcon,@@ -33,6 +34,13 @@ import {VoiceIcon,} from './codex-icons';+export const codexSchema = z.object({+ height: z.number().int().positive(),+ width: z.number().int().positive(),+});++export type CodexProps = z.infer<typeof codexSchema>;+const SidebarNavigation: React.FC = () => {return (<>@@ -186,7 +194,7 @@ const RecentRow: React.FC<{);};-const Sidebar: React.FC = () => {+const Sidebar: React.FC<{readonly height: number}> = ({height}) => {return (<Interactive.Divname="Sidebar"@@ -198,7 +206,7 @@ const Sidebar: React.FC = () => {boxSizing: 'border-box',color: '#393a3c',fontSize: 12.5,- height: 928,+ height,left: 0,position: 'absolute',top: 0,@@ -805,7 +813,7 @@ const Conversation: React.FC = () => {);};-const Composer: React.FC = () => {+const Composer: React.FC<{readonly top: number}> = ({top}) => {return (<Interactive.Divname="Composer"@@ -820,7 +828,7 @@ const Composer: React.FC = () => {height: 90,left: 60,position: 'absolute',- top: 824,+ top,width: 665,}}>@@ -959,36 +967,39 @@ const Composer: React.FC = () => {);};-export const Codex: React.FC = () => {+export const Codex: React.FC<CodexProps> = ({height, width}) => {+ const scale = width / 1081;+ const referenceHeight = height / scale;+return (<AbsoluteFillstyle={{WebkitFontSmoothing: 'antialiased',- backgroundColor: 'transparent',+ backgroundColor: '#ffffff',fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif',fontWeight: 400,+ overflow: 'hidden',}}><Interactive.Divname="Codex window"style={{backgroundColor: '#ffffff',- borderRadius: 10,- boxShadow:- '0 0 0 1px rgba(0, 0, 0, 0.07), 0 0 1px rgba(0, 0, 0, 0.7), 0 18px 42px rgba(0, 0, 0, 0.4)',- height: 928,- left: 56,+ height: referenceHeight,+ left: 0,overflow: 'hidden',position: 'absolute',- top: 38,+ scale,+ top: 0,+ transformOrigin: '0 0',width: 1081,}}>- <Sidebar />+ <Sidebar height={referenceHeight} /><divstyle={{- height: 928,+ height: referenceHeight,left: 296,position: 'absolute',top: 0,@@ -997,7 +1008,7 @@ export const Codex: React.FC = () => {><Header /><Conversation />- <Composer />+ <Composer top={referenceHeight - 104} /></div></Interactive.Div></AbsoluteFill>diff --git a/packages/brand/src/video-elements/Studio.tsx b/packages/brand/src/video-elements/Studio.tsxindex ccd765981e..2cb0363e8c 100644--- a/packages/brand/src/video-elements/Studio.tsx+++ b/packages/brand/src/video-elements/Studio.tsx@@ -84,6 +84,7 @@ export type StudioProps = {readonly durationInFrames: number;readonly frame: number;readonly responsivenessProgress: number;+ readonly viewportHeight: number | null;readonly viewportWidth: number;};@@ -1587,6 +1588,7 @@ const StudioInner = React.forwardRef<durationInFrames,frame,responsivenessProgress,+ viewportHeight,viewportWidth,},ref,@@ -1597,7 +1599,8 @@ const StudioInner = React.forwardRef<() => outlineRef.current as HTMLDivElement,[],);- const {height, fps} = useVideoConfig();+ const {height: videoHeight, fps} = useVideoConfig();+ const height = viewportHeight ?? videoHeight;const width = viewportWidth;const topPanelHeight = Math.round((height - MENU_HEIGHT - SPLITTER_SIZE) * TOP_PANEL_RATIO,@@ -1766,6 +1769,7 @@ export const StudioReference: React.FC<StudioReferenceProps> = ({durationInFrames={742}frame={655}responsivenessProgress={responsivenessProgress}+ viewportHeight={null}viewportWidth={viewportWidth}/>);diff --git a/packages/brand/src/video-elements/StudioCodeHandoff.tsx b/packages/brand/src/video-elements/StudioCodeHandoff.tsxindex 693010410f..c279f56c3b 100644--- a/packages/brand/src/video-elements/StudioCodeHandoff.tsx+++ b/packages/brand/src/video-elements/StudioCodeHandoff.tsx@@ -2,12 +2,14 @@ import {AbsoluteFill,Easing,Interactive,+ Sequence,interpolate,useCurrentFrame,} from 'remotion';+import {Scene11} from '../announcements/whats-new-in-remotion/Scene11';import {MacBookScreen} from '../WebMCPPromo/MacBookScene';import {Codex} from './Codex';-import {StudioReference} from './Studio';+import {Studio} from './Studio';import {TextEditor} from './TextEditor';export const StudioCodeHandoff: React.FC = () => {@@ -18,37 +20,39 @@ export const StudioCodeHandoff: React.FC = () => {<Interactive.Divname="Device frame"style={{- height: 936,- left: 142,+ height: 796,+ left: 92.5,position: 'absolute',- top: 72,- width: 1636,+ scale: 1.25,+ top: 42.5,+ transformOrigin: '0 0',+ width: 1388,}}><MacBookScreen- height={936}+ height={796}left={0}showCameraNotch={false}top={0}- width={1636}+ width={1388}><Interactive.Divname="Screen viewport"style={{backgroundColor: '#101114',borderRadius: 19,- height: 900,+ height: 760,left: 18,overflow: 'hidden',position: 'absolute',top: 18,- width: 1600,+ width: 1352,}}><Interactive.Divname="VS Code"style={{- height: 900,+ height: 760,left: 0,overflow: 'hidden',position: 'absolute',@@ -56,14 +60,14 @@ export const StudioCodeHandoff: React.FC = () => {translate: interpolate(frame,[60, 100],- ['800px 0px', '1600px 0px'],+ ['676px 0px', '1352px 0px'],{easing: Easing.bezier(0.16, 1, 0.3, 1),extrapolateLeft: 'clamp',extrapolateRight: 'clamp',},),- width: 800,+ width: 676,}}><TextEditor@@ -102,9 +106,9 @@ export const Scene11: React.FC = () => {);};`}fileName="Scene11.tsx"- height={900}+ height={760}highlightedLines="14-18"- width={800}+ width={676}/></Interactive.Div>@@ -112,7 +116,7 @@ export const Scene11: React.FC = () => {name="Codex"style={{backgroundColor: '#f4f4f2',- height: 900,+ height: 760,left: 0,overflow: 'hidden',position: 'absolute',@@ -120,7 +124,7 @@ export const Scene11: React.FC = () => {translate: interpolate(frame,[60, 100, 140, 180],- ['-800px 0px', '0px 0px', '0px 0px', '-800px 0px'],+ ['-676px 0px', '0px 0px', '0px 0px', '-676px 0px'],{easing: [Easing.bezier(0.16, 1, 0.3, 1),@@ -131,28 +135,16 @@ export const Scene11: React.FC = () => {extrapolateRight: 'clamp',},),- width: 800,+ width: 676,}}>- <div- style={{- height: 1040,- left: 0,- position: 'absolute',- scale: 800 / 1193,- top: (900 - (1040 * 800) / 1193) / 2,- transformOrigin: '0 0',- width: 1193,- }}- >- <Codex />- </div>+ <Codex height={760} width={676} /></Interactive.Div><Interactive.Divname="Remotion Studio"style={{- height: 900,+ height: 760,left: 0,overflow: 'hidden',position: 'absolute',@@ -160,7 +152,7 @@ export const Scene11: React.FC = () => {translate: interpolate(frame,[60, 100, 140, 180],- ['0px 0px', '800px 0px', '800px 0px', '0px 0px'],+ ['0px 0px', '676px 0px', '676px 0px', '0px 0px'],{easing: [Easing.bezier(0.16, 1, 0.3, 1),@@ -171,7 +163,7 @@ export const Scene11: React.FC = () => {extrapolateRight: 'clamp',},),- width: interpolate(frame, [140, 180], [800, 1600], {+ width: interpolate(frame, [140, 180], [676, 1352], {easing: Easing.bezier(0.16, 1, 0.3, 1),extrapolateLeft: 'clamp',extrapolateRight: 'clamp',@@ -179,40 +171,40 @@ export const Scene11: React.FC = () => {zIndex: 1,}}>- <div- style={{- height: 1080,- left: 0,- position: 'absolute',- scale: 5 / 6,- top: 0,- transformOrigin: '0 0',- width: 1920,- }}- >- <StudioReference- responsivenessProgress={interpolate(- frame,- [140, 180],- [1, 0],- {- easing: Easing.bezier(0.16, 1, 0.3, 1),- extrapolateLeft: 'clamp',- extrapolateRight: 'clamp',- },- )}- viewportWidth={interpolate(- frame,- [140, 180],- [960, 1920],- {- easing: Easing.bezier(0.16, 1, 0.3, 1),- extrapolateLeft: 'clamp',- extrapolateRight: 'clamp',- },- )}- />- </div>+ <Studio+ compositionHeight={1080}+ compositionName="Chapter11-Outro"+ compositionWidth={1920}+ content={+ <Sequence from={-416} layout="none">+ {/* Show Studio frame 655 within this 240-frame composition. */}+ <Scene11 platform="youtube" />+ </Sequence>+ }+ durationInFrames={742}+ frame={655}+ responsivenessProgress={interpolate(+ frame,+ [140, 180],+ [1, 0],+ {+ easing: Easing.bezier(0.16, 1, 0.3, 1),+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ )}+ viewportHeight={760}+ viewportWidth={interpolate(+ frame,+ [140, 180],+ [676, 1352],+ {+ easing: Easing.bezier(0.16, 1, 0.3, 1),+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ )}+ /></Interactive.Div></Interactive.Div></MacBookScreen>diff --git a/packages/brand/src/video-elements/TextEditor.tsx b/packages/brand/src/video-elements/TextEditor.tsxindex ed05cdb4be..cb5cbf486f 100644--- a/packages/brand/src/video-elements/TextEditor.tsx+++ b/packages/brand/src/video-elements/TextEditor.tsx@@ -5,8 +5,8 @@ import {Interactive, useDelayRender} from 'remotion';import {z} from 'zod';import {ReactFileIcon, VscodeIcon} from './vscode-icons';-const REFERENCE_WIDTH = 1399;-const REFERENCE_HEIGHT = 1362;+const REFERENCE_WIDTH = 1287;+const REFERENCE_HEIGHT = 1250;export const textEditorSchema = z.object({code: z.string().describe('Code shown in the editor'),@@ -28,17 +28,13 @@ export const TextEditor: React.FC<TextEditorProps> = ({width,}) => {const scale = Math.min(width / REFERENCE_WIDTH, height / REFERENCE_HEIGHT);- const windowLeft = 56 * scale;- const windowTop = 38 * scale;- const windowWidth = width - windowLeft * 2;- const windowHeight = height - windowTop - 74 * scale;const titleBarHeight = 28 * scale;const tabBarHeight = 34 * scale;const breadcrumbHeight = 22 * scale;const activityBarWidth = 50 * scale;const statusBarHeight = 32 * scale;const editorTop = titleBarHeight + tabBarHeight + breadcrumbHeight;- const editorHeight = windowHeight - editorTop - statusBarHeight;+ const editorHeight = height - editorTop - statusBarHeight;const [highlighted, setHighlighted] = useState<HighlightedCode | null>(null);const {cancelRender, continueRender, delayRender} = useDelayRender();const [handle] = useState(() => delayRender('Highlighting text editor code'));@@ -157,17 +153,16 @@ export const TextEditor: React.FC<TextEditorProps> = ({style={{backgroundColor: '#131414',border: `${scale}px solid #454545`,- borderRadius: 10 * scale,boxSizing: 'border-box',color: '#cccccc',fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif',- height: windowHeight,- left: windowLeft,+ height,+ left: 0,overflow: 'hidden',position: 'absolute',- top: windowTop,- width: windowWidth,+ top: 0,+ width,}}><Interactive.Div