🎥 Make videos programmatically with React
so cool
Jonny Burger1276bae32d50
diff --git a/packages/docs/components/ColorDemo/Colors/index.tsx b/packages/docs/components/ColorDemo/Colors/index.tsxindex 1b4d498e3a..5adf700c0b 100644--- a/packages/docs/components/ColorDemo/Colors/index.tsx+++ b/packages/docs/components/ColorDemo/Colors/index.tsx@@ -1,116 +1,116 @@-import {parseToRgb} from 'polished';-import React from 'react';-import {interpolate, spring, useCurrentFrame, useVideoConfig} from 'remotion';+import { parseToRgb } from "polished";+import React from "react";+import { interpolate, spring, useCurrentFrame, useVideoConfig } from "remotion";const container: React.CSSProperties = {- display: 'flex',- justifyContent: 'center',- alignItems: 'center',- fontFamily:- "--apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif",- fontWeight: 'bold',- fontSize: 30,+ display: "flex",+ justifyContent: "center",+ alignItems: "center",+ fontFamily:+ "--apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif",+ fontWeight: "bold",+ fontSize: 30,};const BAR_SCALE_FACTOR = 1.5;const TOP_PANEL = 100;const row: React.CSSProperties = {- display: 'flex',- flexDirection: 'row',- alignItems: 'flex-end',- height: BAR_SCALE_FACTOR * 255 + TOP_PANEL,+ display: "flex",+ flexDirection: "row",+ alignItems: "flex-end",+ height: BAR_SCALE_FACTOR * 255 + TOP_PANEL,};const bar: React.CSSProperties = {- borderRadius: 10,+ borderRadius: 10,};-const rgb = ['#ff7979', '#badc58', '#3498db'];+const rgb = ["#ff7979", "#badc58", "#3498db"];export const Colors: React.FC<{- color: string;-}> = ({color}) => {- const {fps} = useVideoConfig();- const frame = useCurrentFrame();- const parsed = parseToRgb(color);+ color: string;+}> = ({ color }) => {+ const { fps } = useVideoConfig();+ const frame = useCurrentFrame();+ const parsed = parseToRgb(color);- const progress = spring({- fps,- frame,- config: {- mass: 4,- damping: 200,- },- });+ const progress = spring({+ fps,+ frame,+ config: {+ mass: 4,+ damping: 200,+ },+ });- const barMargin = interpolate(progress, [0, 1], [0, 20]);+ const barMargin = interpolate(progress, [0, 1], [0, 20]);- return (- <div- style={{- ...container,- flex: 1,- justifyContent: 'center',- alignItems: 'center',- backgroundColor: 'white',- }}- >- <div style={row}>- {[parsed.red, parsed.green, parsed.blue].map((color, index) => {- const barProgress = spring({- fps,- frame: frame - index * 10,- config: {- mass: 1.4,- damping: 200,- },- });- return (- <div style={{textAlign: 'center'}}>- <div- style={{- height: TOP_PANEL,- marginBottom: 10,- color: rgb[index],- overflow: 'hidden',- }}- >- <span style={{opacity: barProgress, fontSize: 80}}>- {String(color)}- </span>- </div>- <div- key={index}- style={{- ...bar,- width: 250,- marginLeft: barMargin,- marginRight: barMargin,- height: color * BAR_SCALE_FACTOR * barProgress,- backgroundColor: rgb[index],- }}- />- <div- style={{marginTop: 20, color: rgb[index], overflow: 'hidden'}}- >- <span- style={{- transform: `translateY(${interpolate(- barProgress,- [0, 1],- [30, 0]- )}px)`,- display: 'block',- }}- >- {['Red', 'Green', 'Blue'][index]}- </span>- </div>- </div>- );- })}- </div>- </div>- );+ return (+ <div+ style={{+ ...container,+ flex: 1,+ justifyContent: "center",+ alignItems: "center",+ backgroundColor: "white",+ }}+ >+ <div style={row}>+ {[parsed.red, parsed.green, parsed.blue].map((color, index) => {+ const barProgress = spring({+ fps,+ frame: frame - index * 10,+ config: {+ mass: 1.4,+ damping: 200,+ },+ });+ return (+ <div style={{ textAlign: "center" }}>+ <div+ style={{+ height: TOP_PANEL,+ marginBottom: 10,+ color: rgb[index],+ overflow: "hidden",+ }}+ >+ <span style={{ opacity: barProgress, fontSize: 80 }}>+ {String(color)}+ </span>+ </div>+ <div+ key={index}+ style={{+ ...bar,+ width: 250,+ marginLeft: barMargin,+ marginRight: barMargin,+ height: color * BAR_SCALE_FACTOR * barProgress,+ backgroundColor: rgb[index],+ }}+ />+ <div+ style={{ marginTop: 20, color: rgb[index], overflow: "hidden" }}+ >+ <span+ style={{+ transform: `translateY(${interpolate(+ barProgress,+ [0, 1],+ [70, 0]+ )}px)`,+ display: "block",+ }}+ >+ {["Red", "Green", "Blue"][index]}+ </span>+ </div>+ </div>+ );+ })}+ </div>+ </div>+ );};diff --git a/packages/docs/components/ColorDemo/Name.tsx b/packages/docs/components/ColorDemo/Name.tsxindex 38a90bf21e..ae6c71cbf5 100644--- a/packages/docs/components/ColorDemo/Name.tsx+++ b/packages/docs/components/ColorDemo/Name.tsx@@ -35,6 +35,7 @@ export const Name: React.FC<{flex: 1,fontSize: 100,backgroundColor: "white",+ color: "black",}}><div>@@ -49,7 +50,7 @@ export const Name: React.FC<{lineHeight: 1.1,}}>- Hi {name}!+ Hi {name || "there"}!</span><spanstyle={{diff --git a/packages/docs/components/Player.tsx b/packages/docs/components/Player.tsxindex 7f6bfb09e8..9bdf3c7c04 100644--- a/packages/docs/components/Player.tsx+++ b/packages/docs/components/Player.tsx@@ -1,7 +1,8 @@import { Player } from "@remotion/player";-import React from "react";+import React, { useState } from "react";import { useCurrentFrame } from "remotion";import { Main } from "./ColorDemo/Main";+import "./player.css";const Comp: React.FC = () => {const frame = useCurrentFrame();@@ -9,24 +10,47 @@ const Comp: React.FC = () => {};export const PlayerExample: React.FC = () => {+ const [name, setName] = useState("");++ const [color, setColor] = useState("#4098f5");return (- <Player- component={Main}- compositionWidth={1280}- compositionHeight={720}- controls- durationInFrames={350}- fps={30}- inputProps={{- name: "Jonny",- color: "#d4afdf",- }}- style={{- aspectRatio: "16 / 9",- height: undefined,- width: "100%",- }}- loop- ></Player>+ <div>+ <Player+ component={Main}+ compositionWidth={1280}+ compositionHeight={720}+ controls+ durationInFrames={350}+ fps={30}+ inputProps={{+ name,+ color,+ }}+ style={{+ aspectRatio: "16 / 9",+ height: undefined,+ width: "100%",+ }}+ loop+ ></Player>+ <br />+ <p>+ Enter your name:{" "}+ <input+ type="text"+ placeholder="Your name"+ value={name}+ onChange={(e) => setName(e.target.value)}+ />+ </p>+ <p>+ Select your favorite color:{" "}+ <input+ type="color"+ value={color}+ onChange={(e) => setColor(e.target.value)}+ />+ </p>+ </div>);};diff --git a/packages/docs/components/player.css b/packages/docs/components/player.cssnew file mode 100644index 0000000000..ea79064c55--- /dev/null+++ b/packages/docs/components/player.css@@ -0,0 +1,11 @@+input[type="text"] {+ padding: 13px;+ font-family: inherit;+ border: 2px solid var(--ifm-code-background);+ border-radius: 6px;+ background-color: transparent;+ outline: none;+}+input[type="text"]:focus {+ border-color: var(--ifm-tabs-color-active);+}diff --git a/packages/docs/docs/player.md b/packages/docs/docs/player.mdindex 527d49b755..4b3bfc1c5a 100644--- a/packages/docs/docs/player.md+++ b/packages/docs/docs/player.md@@ -10,7 +10,7 @@ import { ExperimentalBadge } from "../components/Experimental.tsx";<ExperimentalBadge/>-Using the Remotion Player you can embed Remotion videos in any React app and customize the video content at runtime.+Using the Remotion Player you can embed Remotion videos in any React app and customize the video content at runtime. Play the video, then tweak the parameters below the video.<PlayerExample />## Installation