🎥 Make videos programmatically with React
remix template
Jonny Burger20d4e16af790
diff --git a/packages/create-video/src/templates.ts b/packages/create-video/src/templates.tsindex 7438a7c5b8..f12cb100f3 100644--- a/packages/create-video/src/templates.ts+++ b/packages/create-video/src/templates.ts@@ -1,3 +1,21 @@+type DynamicTemplate =+ | {+ type: 'video';+ promoVideo: {+ muxId: string;+ width: number;+ height: number;+ };+ }+ | {+ type: 'image';+ promoBanner: {+ src: string;+ width: number;+ height: number;+ };+ };+export type Template = {shortName: string;description: string;@@ -5,13 +23,8 @@ export type Template = {repoName: string;homePageLabel: string;longerDescription: string;- promoVideo: {- muxId: string;- width: number;- height: number;- };cliId: string;-};+} & DynamicTemplate;export const FEATURED_TEMPLATES: Template[] = [{@@ -28,6 +41,7 @@ export const FEATURED_TEMPLATES: Template[] = [width: 1920,},cliId: 'hello-world',+ type: 'video',},{homePageLabel: 'JavaScript',@@ -43,6 +57,7 @@ export const FEATURED_TEMPLATES: Template[] = [height: 1080,},cliId: 'javascript',+ type: 'video',},{homePageLabel: 'Blank',@@ -58,6 +73,23 @@ export const FEATURED_TEMPLATES: Template[] = [height: 720,},cliId: 'blank',+ type: 'video',+ },+ {+ homePageLabel: 'Remix',+ shortName: 'Remix',+ org: 'florentpergoud',+ repoName: 'remotion-remix-template',+ description: 'Remotion + React Three Fiber Starter Template',+ longerDescription:+ 'A software-as-a-service starter kit which has the Remotion Player and rendering via Remotion Lambda built-in. Built with remix.run.',+ promoBanner: {+ width: 1280,+ height: 720,+ src: '/img/remix-template.png',+ },+ cliId: 'remix',+ type: 'image',},{homePageLabel: '3D',@@ -73,6 +105,7 @@ export const FEATURED_TEMPLATES: Template[] = [height: 720,},cliId: 'three',+ type: 'video',},{homePageLabel: 'Stills',@@ -88,6 +121,7 @@ export const FEATURED_TEMPLATES: Template[] = [width: 1200,},cliId: 'still',+ type: 'video',},{homePageLabel: 'TTS',@@ -103,6 +137,7 @@ export const FEATURED_TEMPLATES: Template[] = [height: 1080,},cliId: 'tts',+ type: 'video',},{homePageLabel: 'Audiogram',@@ -118,6 +153,7 @@ export const FEATURED_TEMPLATES: Template[] = [width: 1080,},cliId: 'audiogram',+ type: 'video',},{homePageLabel: 'Skia',@@ -132,6 +168,7 @@ export const FEATURED_TEMPLATES: Template[] = [width: 1920,},cliId: 'skia',+ type: 'video',},{homePageLabel: 'Tailwind',@@ -147,5 +184,6 @@ export const FEATURED_TEMPLATES: Template[] = [width: 1280,},cliId: 'tailwind',+ type: 'video',},];diff --git a/packages/docs/src/components/ChooseTemplate.tsx b/packages/docs/src/components/ChooseTemplate.tsxindex 4e4de01d9f..89eae518e0 100644--- a/packages/docs/src/components/ChooseTemplate.tsx+++ b/packages/docs/src/components/ChooseTemplate.tsx@@ -7,6 +7,7 @@ import { NavigateLeft, NavigateRight } from "./ArrowRight";import { Blank } from "./icons/blank";import { Cubes } from "./icons/cubes";import { JSIcon } from "./icons/js";+import { RemixIcon } from "./icons/remix";import { SkiaIcon } from "./icons/skia";import { StillIcon } from "./icons/still";import { Tailwind } from "./icons/tailwind";@@ -109,6 +110,16 @@ const IconForTemplate: React.FC<{);}+ if (template.homePageLabel === "Remix") {+ return (+ <RemixIcon+ style={{+ height: 32,+ }}+ />+ );+ }+return (<Blankstyle={{diff --git a/packages/docs/src/components/TemplateModalContent.tsx b/packages/docs/src/components/TemplateModalContent.tsxindex c48ef232c4..a547324300 100644--- a/packages/docs/src/components/TemplateModalContent.tsx+++ b/packages/docs/src/components/TemplateModalContent.tsx@@ -98,6 +98,28 @@ const separator: React.CSSProperties = {let copyTimeout: NodeJS.Timeout | null = null;+const layout = ({+ template,+ containerHeight,+ possibleVideoWidth,+}: {+ template: Template;+ containerHeight: number;+ possibleVideoWidth: number;+}) => {+ const dimensions =+ template.type === "video" ? template.promoVideo : template.promoBanner;+ const heightRatio = (containerHeight ?? 0) / dimensions.height;+ const widthRatio = (possibleVideoWidth ?? 0) / dimensions.width;++ const ratio = Math.min(heightRatio, widthRatio);++ const height = ratio * dimensions.height;+ const width = ratio * dimensions.width;++ return { height, width };+};+export const TemplateModalContent: React.FC<{template: Template;onDismiss: () => void;@@ -133,13 +155,11 @@ export const TemplateModalContent: React.FC<{? Infinity: Math.min(containerSize?.height ?? 0, 800);- const heightRatio = (containerHeight ?? 0) / template.promoVideo.height;- const widthRatio = (possibleVideoWidth ?? 0) / template.promoVideo.width;-- const ratio = Math.min(heightRatio, widthRatio);-- const height = ratio * template.promoVideo.height;- const width = ratio * template.promoVideo.width;+ const { height, width } = layout({+ template,+ containerHeight,+ possibleVideoWidth,+ });const loadingStyle = useMemo(() => {return {@@ -195,19 +215,31 @@ export const TemplateModalContent: React.FC<{<Spinner style={spinner} /></div>)}- <MuxVideo- muxId={template.promoVideo.muxId}- loop- height={height}- width={width}- autoPlay- muted- playsInline- style={{- display: "inline-flex",- }}- onLoadedMetadata={onLoadedMetadata}- />+ {template.type === "video" ? (+ <MuxVideo+ muxId={template.promoVideo.muxId}+ loop+ height={height}+ width={width}+ autoPlay+ muted+ playsInline+ style={{+ display: "inline-flex",+ }}+ onLoadedMetadata={onLoadedMetadata}+ />+ ) : (+ <img+ src={template.promoBanner.src}+ height={height}+ width={width}+ style={{+ display: "inline-flex",+ }}+ onLoad={onLoadedMetadata}+ />+ )}</div><divstyle={{diff --git a/packages/docs/src/components/icons/remix.tsx b/packages/docs/src/components/icons/remix.tsxnew file mode 100644index 0000000000..b1bafbcc89--- /dev/null+++ b/packages/docs/src/components/icons/remix.tsx@@ -0,0 +1,25 @@+import type { SVGProps } from "react";+import React from "react";++export const RemixIcon: React.FC<SVGProps<SVGSVGElement>> = (props) => {+ return (+ <svg+ width="800"+ height="800"+ viewBox="0 0 800 800"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ fillRule="evenodd"+ clipRule="evenodd"+ d="M621.609 552.632C626.649 617.449 626.649 647.833 626.649 681H476.823C476.823 673.776 476.952 667.167 477.082 660.466C477.488 639.634 477.911 617.911 474.538 574.041C470.082 509.814 442.451 495.543 391.645 495.543H346.633H156V378.687H398.776C462.951 378.687 495.04 359.146 495.04 307.408C495.04 261.915 462.951 234.347 398.776 234.347H156V120H425.516C570.802 120 643 188.686 643 298.405C643 380.471 592.194 433.993 523.562 442.913C581.498 454.509 615.369 487.514 621.609 552.632Z"+ fill="currentcolor"+ />+ <path+ d="M156 681V593H313.899C340.273 593 346 612.845 346 624.68V681H156Z"+ fill="currentcolor"+ />+ </svg>+ );+};diff --git a/packages/docs/static/img/remix-template.png b/packages/docs/static/img/remix-template.pngnew file mode 100644index 0000000000..e4ae52b848Binary files /dev/null and b/packages/docs/static/img/remix-template.png differ