🎥 Make videos programmatically with React
animated emoji
Jonny Burgerbd24cb30b6f8
diff --git a/packages/animated-emojis/package.json b/packages/animated-emoji/package.jsonsimilarity index 95%rename from packages/animated-emojis/package.jsonrename to packages/animated-emoji/package.jsonindex c28f29470c..c8a6a0886d 100644--- a/packages/animated-emojis/package.json+++ b/packages/animated-emoji/package.json@@ -1,5 +1,5 @@{- "name": "@remotion/animated-emojis",+ "name": "@remotion/animated-emoji","version": "4.0.186","main": "dist/cjs/index.js","types": "dist/cjs/index.d.ts",diff --git a/packages/animated-emoji/src/AnimatedEmoji.tsx b/packages/animated-emoji/src/AnimatedEmoji.tsxnew file mode 100644index 0000000000..bf75264288--- /dev/null+++ b/packages/animated-emoji/src/AnimatedEmoji.tsx@@ -0,0 +1,45 @@+import {+ Loop,+ OffthreadVideo,+ RemotionOffthreadVideoProps,+ useVideoConfig,+} from 'remotion';+import {+ CalculateEmojiSrc,+ Scale,+ defaultCalculateEmojiSrc,+} from './calculate-emoji-src';+import {emojis} from './emoji-data';+import type {EmojiName} from './get-available-emojis';+import {isWebkit} from './is-webkit';++export type AnimatedEmojiProps = Omit<RemotionOffthreadVideoProps, 'src'> & {+ emoji: EmojiName;+ scale?: Scale;+ calculateSrc?: CalculateEmojiSrc;+};++export const AnimatedEmoji = ({+ emoji,+ scale = '1',+ calculateSrc = defaultCalculateEmojiSrc,+ ...props+}: AnimatedEmojiProps) => {+ const {fps} = useVideoConfig();++ const emojiData = emojis.find((e) => e.name === emoji);+ if (!emojiData) {+ throw new Error(+ `Emoji ${emoji} not found. Available emojis: ${emojis.map((e) => e.name).join(', ')}`,+ );+ }++ return (+ <Loop durationInFrames={Math.floor(emojiData.durationInSeconds * fps)}>+ <OffthreadVideo+ {...props}+ src={calculateSrc({emoji, scale, format: isWebkit() ? 'hevc' : 'webm'})}+ />+ </Loop>+ );+};diff --git a/packages/animated-emoji/src/calculate-emoji-src.ts b/packages/animated-emoji/src/calculate-emoji-src.tsnew file mode 100644index 0000000000..6f2a8bfa13--- /dev/null+++ b/packages/animated-emoji/src/calculate-emoji-src.ts@@ -0,0 +1,21 @@+import {staticFile} from 'remotion';+import {EmojiName} from './get-available-emojis';++export type Format = 'hevc' | 'webm';+export type Scale = '0.5' | '1' | '2';++export type CalculateEmojiSrc = (options: {+ emoji: EmojiName;+ scale: Scale;+ format: Format;+}) => string;++export const defaultCalculateEmojiSrc: CalculateEmojiSrc = ({+ emoji,+ scale,+ format,+}) => {+ const extension = format === 'hevc' ? 'mp4' : 'webm';++ return staticFile(`${emoji}-${scale}x.${extension}`);+};diff --git a/packages/animated-emojis/src/emoji-data.ts b/packages/animated-emoji/src/emoji-data.tssimilarity index 100%rename from packages/animated-emojis/src/emoji-data.tsrename to packages/animated-emoji/src/emoji-data.tsdiff --git a/packages/animated-emojis/src/get-available-emojis.ts b/packages/animated-emoji/src/get-available-emojis.tssimilarity index 100%rename from packages/animated-emojis/src/get-available-emojis.tsrename to packages/animated-emoji/src/get-available-emojis.tsdiff --git a/packages/animated-emojis/src/index.ts b/packages/animated-emoji/src/index.tssimilarity index 100%rename from packages/animated-emojis/src/index.tsrename to packages/animated-emoji/src/index.tsdiff --git a/packages/animated-emoji/src/is-webkit.ts b/packages/animated-emoji/src/is-webkit.tsnew file mode 100644index 0000000000..10a09143f2--- /dev/null+++ b/packages/animated-emoji/src/is-webkit.ts@@ -0,0 +1,12 @@+export const isWebkit = () => {+ if (typeof window === 'undefined') {+ return false;+ }++ const isSafariUserAgent = Boolean(+ navigator.userAgent.match(/Version\/[\d.]+.*Safari/),+ );++ const isChrome = Boolean(navigator.userAgent.match(/CriOS\//));+ return isSafariUserAgent || isChrome;+};diff --git a/packages/animated-emojis/tsconfig.json b/packages/animated-emoji/tsconfig.jsonsimilarity index 100%rename from packages/animated-emojis/tsconfig.jsonrename to packages/animated-emoji/tsconfig.jsondiff --git a/packages/animated-emojis/src/AnimatedEmoji.tsx b/packages/animated-emojis/src/AnimatedEmoji.tsxdeleted file mode 100644index 63ee2c2468..0000000000--- a/packages/animated-emojis/src/AnimatedEmoji.tsx+++ /dev/null@@ -1,19 +0,0 @@-import {- OffthreadVideo,- RemotionOffthreadVideoProps,- staticFile,-} from 'remotion';-import {EmojiName} from './get-available-emojis';--export type Scale = '0.5' | '1' | '2';--export type AnimatedEmojiProps = Omit<RemotionOffthreadVideoProps, 'src'> & {- emoji: EmojiName;- scale: Scale;-};--export const AnimatedEmoji = ({emoji, scale, ...props}: AnimatedEmojiProps) => {- return (- <OffthreadVideo {...props} src={staticFile(`${emoji}-${scale}x.mp4`)} />- );-};diff --git a/packages/cli/src/list-of-remotion-packages.ts b/packages/cli/src/list-of-remotion-packages.tsindex c42be2d342..a408d663d2 100644--- a/packages/cli/src/list-of-remotion-packages.ts+++ b/packages/cli/src/list-of-remotion-packages.ts@@ -31,6 +31,6 @@ export const listOfRemotionPackages = ['@remotion/transitions','@remotion/install-whisper-cpp','@remotion/animation-utils',- '@remotion/animated-emojis',+ '@remotion/animated-emoji','remotion',];diff --git a/packages/create-video/src/list-of-remotion-packages.ts b/packages/create-video/src/list-of-remotion-packages.tsindex b860e868f3..4087328189 100644--- a/packages/create-video/src/list-of-remotion-packages.ts+++ b/packages/create-video/src/list-of-remotion-packages.ts@@ -31,6 +31,6 @@ export const listOfRemotionPackages = ['@remotion/transitions','@remotion/install-whisper-cpp','@remotion/animation-utils',- '@remotion/animated-emojis',+ '@remotion/animated-emoji','remotion',];diff --git a/packages/docs/components/TableOfContents/api.tsx b/packages/docs/components/TableOfContents/api.tsxindex b58f07b2c3..8e52268232 100644--- a/packages/docs/components/TableOfContents/api.tsx+++ b/packages/docs/components/TableOfContents/api.tsx@@ -1,114 +1,118 @@-import React from "react";-import { Grid } from "./Grid";-import { TOCItem } from "./TOCItem";+import React from 'react';+import {Grid} from './Grid';+import {TOCItem} from './TOCItem';export const TableOfContents: React.FC = () => {- return (- <div>- <Grid>- <TOCItem link="/docs/cli">- <strong>Command line</strong>- <div>- Reference for the <code>npx remotion</code> commands- </div>- </TOCItem>- <TOCItem link="/docs/config">- <strong>Configuration file</strong>- <div>- Reference for the <code>remotion.config.ts</code> file- </div>- </TOCItem>- </Grid>- <h2>Packages</h2>- <Grid>- <TOCItem link="/docs/remotion">- <strong>remotion</strong>- <div>- Core APIs: <code>useCurrentFrame()</code>,{" "}- <code>interpolate()</code>, etc.- </div>- </TOCItem>- <TOCItem link="/docs/bundler">- <strong>@remotion/bundler</strong>- <div>Create a Webpack bundle from Node.JS</div>- </TOCItem>- <TOCItem link="/docs/player">- <strong>@remotion/player</strong>- <div>Play a Remotion video in the browser</div>- </TOCItem>- <TOCItem link="/docs/lambda">- <strong>@remotion/lambda</strong>- <div>Render videos and stills on AWS Lambda</div>- </TOCItem>- <TOCItem link="/docs/cloudrun">- <strong>@remotion/cloudrun</strong>- <div>Render videos and stills on GCP Cloud Run</div>- </TOCItem>- <TOCItem link="/docs/gif">- <strong>@remotion/gif</strong>- <div>Include a GIF in your video</div>- </TOCItem>- <TOCItem link="/docs/media-utils">- <strong>@remotion/media-utils</strong>- <div>Obtain info about video and audio</div>- </TOCItem>- <TOCItem link="/docs/animation-utils">- <strong>@remotion/animation-utils</strong>- <div>Animation utilities</div>- </TOCItem>- <TOCItem link="/docs/tailwind/tailwind">- <strong>@remotion/tailwind</strong>- <div>Webpack override for using TailwindCSS</div>- </TOCItem>- <TOCItem link="/docs/enable-scss/overview">- <strong>@remotion/enable-scss</strong>- <div>Webpack override for enabling SASS/SCSS</div>- </TOCItem>- <TOCItem link="/docs/three">- <strong>@remotion/three</strong>- <div>Create 3D videos using React Three Fiber</div>- </TOCItem>- <TOCItem link="/docs/skia">- <strong>@remotion/skia</strong>- <div>Low-level graphics using React Native Skia</div>- </TOCItem>- <TOCItem link="/docs/lottie">- <strong>@remotion/lottie</strong>- <div>Include a Lottie animation in your video</div>- </TOCItem>- <TOCItem link="/docs/preload">- <strong>@remotion/preload</strong>- <div>Preload video and audio in the Player</div>- </TOCItem>- <TOCItem link="/docs/renderer">- <strong>@remotion/renderer</strong>- <div>Render video, audio and stills from Node.JS</div>- </TOCItem>- <TOCItem link="/docs/paths">- <strong>@remotion/paths</strong>- <div>Manipulate and obtain info about SVG paths</div>- </TOCItem>- <TOCItem link="/docs/noise">- <strong>@remotion/noise</strong>- <div>Generate noise effects</div>- </TOCItem>- <TOCItem link="/docs/shapes">- <strong>@remotion/shapes</strong>- <div>Generate SVG shapes</div>- </TOCItem>- <TOCItem link="/docs/transitions">- <strong>@remotion/transitions</strong>- <div>Transition between scenes</div>- </TOCItem>- <TOCItem link="/docs/layout-utils">- <strong>@remotion/layout-utils</strong>- <div>Layout helpers</div>- </TOCItem>- <TOCItem link="/docs/install-whisper-cpp">- <strong>@remotion/install-whisper-cpp</strong>- <div>Cross-platform Whisper.cpp installation</div>- </TOCItem>- </Grid>- </div>- );+ return (+ <div>+ <Grid>+ <TOCItem link="/docs/cli">+ <strong>Command line</strong>+ <div>+ Reference for the <code>npx remotion</code> commands+ </div>+ </TOCItem>+ <TOCItem link="/docs/config">+ <strong>Configuration file</strong>+ <div>+ Reference for the <code>remotion.config.ts</code> file+ </div>+ </TOCItem>+ </Grid>+ <h2>Packages</h2>+ <Grid>+ <TOCItem link="/docs/remotion">+ <strong>remotion</strong>+ <div>+ Core APIs: <code>useCurrentFrame()</code>,{' '}+ <code>interpolate()</code>, etc.+ </div>+ </TOCItem>+ <TOCItem link="/docs/bundler">+ <strong>@remotion/bundler</strong>+ <div>Create a Webpack bundle from Node.JS</div>+ </TOCItem>+ <TOCItem link="/docs/player">+ <strong>@remotion/player</strong>+ <div>Play a Remotion video in the browser</div>+ </TOCItem>+ <TOCItem link="/docs/lambda">+ <strong>@remotion/lambda</strong>+ <div>Render videos and stills on AWS Lambda</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun">+ <strong>@remotion/cloudrun</strong>+ <div>Render videos and stills on GCP Cloud Run</div>+ </TOCItem>+ <TOCItem link="/docs/gif">+ <strong>@remotion/gif</strong>+ <div>Include a GIF in your video</div>+ </TOCItem>+ <TOCItem link="/docs/media-utils">+ <strong>@remotion/media-utils</strong>+ <div>Obtain info about video and audio</div>+ </TOCItem>+ <TOCItem link="/docs/animation-utils">+ <strong>@remotion/animation-utils</strong>+ <div>Animation utilities</div>+ </TOCItem>+ <TOCItem link="/docs/tailwind/tailwind">+ <strong>@remotion/tailwind</strong>+ <div>Webpack override for using TailwindCSS</div>+ </TOCItem>+ <TOCItem link="/docs/enable-scss/overview">+ <strong>@remotion/enable-scss</strong>+ <div>Webpack override for enabling SASS/SCSS</div>+ </TOCItem>+ <TOCItem link="/docs/three">+ <strong>@remotion/three</strong>+ <div>Create 3D videos using React Three Fiber</div>+ </TOCItem>+ <TOCItem link="/docs/skia">+ <strong>@remotion/skia</strong>+ <div>Low-level graphics using React Native Skia</div>+ </TOCItem>+ <TOCItem link="/docs/lottie">+ <strong>@remotion/lottie</strong>+ <div>Include a Lottie animation in your video</div>+ </TOCItem>+ <TOCItem link="/docs/preload">+ <strong>@remotion/preload</strong>+ <div>Preload video and audio in the Player</div>+ </TOCItem>+ <TOCItem link="/docs/renderer">+ <strong>@remotion/renderer</strong>+ <div>Render video, audio and stills from Node.JS</div>+ </TOCItem>+ <TOCItem link="/docs/paths">+ <strong>@remotion/paths</strong>+ <div>Manipulate and obtain info about SVG paths</div>+ </TOCItem>+ <TOCItem link="/docs/noise">+ <strong>@remotion/noise</strong>+ <div>Generate noise effects</div>+ </TOCItem>+ <TOCItem link="/docs/shapes">+ <strong>@remotion/shapes</strong>+ <div>Generate SVG shapes</div>+ </TOCItem>+ <TOCItem link="/docs/transitions">+ <strong>@remotion/transitions</strong>+ <div>Transition between scenes</div>+ </TOCItem>+ <TOCItem link="/docs/layout-utils">+ <strong>@remotion/layout-utils</strong>+ <div>Layout helpers</div>+ </TOCItem>+ <TOCItem link="/docs/install-whisper-cpp">+ <strong>@remotion/install-whisper-cpp</strong>+ <div>Cross-platform Whisper.cpp installation</div>+ </TOCItem>+ <TOCItem link="/docs/animated-emoji">+ <strong>@remotion/animated-emoji</strong>+ <div>Google Fonts Animated Emojis as Remotion Components</div>+ </TOCItem>+ </Grid>+ </div>+ );};diff --git a/packages/docs/docs/animated-emojis/TableOfContents.tsx b/packages/docs/docs/animated-emojis/TableOfContents.tsxindex d7b24d0837..d7398b4de3 100644--- a/packages/docs/docs/animated-emojis/TableOfContents.tsx+++ b/packages/docs/docs/animated-emojis/TableOfContents.tsx@@ -6,15 +6,15 @@ export const TableOfContents: React.FC = () => {return (<div><Grid>- <TOCItem link="/docs/animated-emojis/animated-emoji">+ <TOCItem link="/docs/animated-emoji/animated-emoji"><strong>{"<AnimatedEmoji>"}</strong><div>Component for rendering an animated emoji.</div></TOCItem>- <TOCItem link="/docs/animated-emojis/get-available-emojis">+ <TOCItem link="/docs/animated-emoji/get-available-emojis"><strong>{"getAvailableEmojis()"}</strong>- <div>Get a list of available emojis.</div>+ <div>Get a list of available emoji.</div></TOCItem></Grid></div>diff --git a/packages/docs/docs/animated-emojis/index.mdx b/packages/docs/docs/animated-emojis/index.mdxnew file mode 100644index 0000000000..a0108cdd7e--- /dev/null+++ b/packages/docs/docs/animated-emojis/index.mdx@@ -0,0 +1,20 @@+---+sidebar_label: Overview+title: "@remotion/animated-emoji"+---++import Tabs from "@theme/Tabs";+import TabItem from "@theme/TabItem";+import { TableOfContents } from "./TableOfContents";++This package wraps the [Google Fonts Animated Emojis](https://googlefonts.github.io/noto-emoji-animation/) into Remotion components.++## Installation++<Installation pkg="@remotion/animated-emoji" />++## APIs++The following APIs are available:++<TableOfContents />diff --git a/packages/example/package.json b/packages/example/package.jsonindex 265613eba8..d4fcceb7c8 100644--- a/packages/example/package.json+++ b/packages/example/package.json@@ -30,7 +30,7 @@"@mdx-js/react": "^2.3.0","@react-three/drei": "9.88.7","@react-three/fiber": "8.13.5",- "@remotion/animated-emojis": "workspace:*",+ "@remotion/animated-emoji": "workspace:*","@remotion/babel-loader": "workspace:*","@remotion/bundler": "workspace:*","@remotion/cli": "workspace:*",diff --git a/packages/example/src/AnimatedEmojis/index.tsx b/packages/example/src/AnimatedEmojis/index.tsxindex 4347e85568..82cd298b88 100644--- a/packages/example/src/AnimatedEmojis/index.tsx+++ b/packages/example/src/AnimatedEmojis/index.tsx@@ -1,4 +1,4 @@-import {AnimatedEmoji} from '@remotion/animated-emojis';+import {AnimatedEmoji} from '@remotion/animated-emoji';export const UseanimatedEmojis: React.FC = () => {return <AnimatedEmoji emoji="blush" scale="1" />;diff --git a/packages/example/src/webpack-override.mjs b/packages/example/src/webpack-override.mjsindex 526ab8d521..2516a1f7a7 100644--- a/packages/example/src/webpack-override.mjs+++ b/packages/example/src/webpack-override.mjs@@ -27,7 +27,7 @@ const aliases = {'@remotion/shapes': resolveCwd('@remotion/shapes'),'@remotion/studio/internals': resolveCwd('@remotion/studio/internals'),'@remotion/studio': resolveCwd('@remotion/studio'),- '@remotion/animated-emojis': resolveCwd('@remotion/animated-emojis'),+ '@remotion/animated-emoji': resolveCwd('@remotion/animated-emoji'),'@remotion/skia': resolveCwd('@remotion/skia'),'@remotion/three': resolveCwd('@remotion/three'),'@remotion/transitions/fade': resolveCwd('@remotion/transitions/fade'),diff --git a/packages/example/tsconfig.json b/packages/example/tsconfig.jsonindex 27e4dc86a0..f9c6f481bc 100644--- a/packages/example/tsconfig.json+++ b/packages/example/tsconfig.json@@ -12,7 +12,7 @@},"include": ["src"],"references": [- {"path": "../animated-emojis"},+ {"path": "../animated-emoji"},{"path": "../animation-utils"},{"path": "../core"},{"path": "../babel-loader"},diff --git a/packages/it-tests/src/monorepo/get-all-packages.ts b/packages/it-tests/src/monorepo/get-all-packages.tsindex 0ee1e6dd26..95ef0b1df6 100644--- a/packages/it-tests/src/monorepo/get-all-packages.ts+++ b/packages/it-tests/src/monorepo/get-all-packages.ts@@ -5,7 +5,7 @@ import path from 'path';export const packages = ['ai-improvements','animation-utils',- 'animated-emojis',+ 'animated-emoji','astro-example','babel-loader','bugs',@@ -179,7 +179,7 @@ export const descriptions: {[key in Pkgs]: string | null} = {'discord-poster': null,'cli-autocomplete': null,'docusaurus-plugin': null,- 'animated-emojis': 'Google Fonts Animated Emojis as Remotion components',+ 'animated-emoji': 'Google Fonts Animated Emojis as Remotion components',};export const apiDocs: {[key in Pkgs]: string | null} = {@@ -244,5 +244,5 @@ export const apiDocs: {[key in Pkgs]: string | null} = {streaming: null,studio: null,transitions: 'https://www.remotion.dev/transitions',- 'animated-emojis': 'https://www.remotion.dev/docs/animated-emojis',+ 'animated-emoji': 'https://www.remotion.dev/docs/animated-emoji',};diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex c1c3238e88..4c422531f9 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -708,7 +708,7 @@ importers:'@react-three/fiber':specifier: 8.13.5- '@remotion/animated-emojis':+ '@remotion/animated-emoji':specifier: workspace:*version: link:../animated-emojis'@remotion/babel-loader':diff --git a/tsconfig.json b/tsconfig.jsonindex df8eed50da..12997fb879 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -145,7 +145,7 @@"path": "./packages/docusaurus-plugin"},{- "path": "./packages/animated-emojis"+ "path": "./packages/animated-emoji"},{"path": "./packages/zod-types"