Skip to content

🎥 Make videos programmatically with React

add base for animated image (tests, imports, components), minus implementation

Mohit Yadav8e354953a679
diff --git a/packages/core/src/animate-image/AnimatedImage.tsx b/packages/core/src/animate-image/AnimatedImage.tsx
new file mode 100644
index 0000000000..d4d3636453
--- /dev/null
+++ b/packages/core/src/animate-image/AnimatedImage.tsx
@@ -0,0 +1,3 @@
+export const AnimatedImage = ({src}: {readonly src: string}) => {
+ return <div>Animated image{src}</div>;
+};
diff --git a/packages/core/src/animate-image/index.ts b/packages/core/src/animate-image/index.ts
new file mode 100644
index 0000000000..3226392e2c
--- /dev/null
+++ b/packages/core/src/animate-image/index.ts
@@ -0,0 +1 @@
+export {AnimatedImage} from './AnimatedImage';
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index a5602569fe..2de6b9c873 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -92,6 +92,7 @@ export type BundleState =
checkMultipleRemotionVersions();
export * from './AbsoluteFill.js';
+export * from './animate-image/index.js';
export {Artifact} from './Artifact.js';
export * from './audio/index.js';
export {cancelRender} from './cancel-render.js';
diff --git a/packages/core/src/test/animated-image.test.tsx b/packages/core/src/test/animated-image.test.tsx
new file mode 100644
index 0000000000..bef2ff84db
--- /dev/null
+++ b/packages/core/src/test/animated-image.test.tsx
@@ -0,0 +1,16 @@
+/**
+ * @vitest-environment jsdom
+ */
+import {render} from '@testing-library/react';
+import {describe, expect, test} from 'vitest';
+import {AnimatedImage} from '../animate-image';
+
+describe('Render correctly with props', () => {
+ test('should render with default props', () => {
+ expect(() =>
+ render(
+ <AnimatedImage src="https://gist.github.com/nolanlawson/73f15f3fe612b8770e79/raw/be4205effd089b38ccd197de544e6370785f6b5e/chopsticks.gif" />,
+ ),
+ ).not.toThrow();
+ });
+});
diff --git a/packages/example/src/AnimatedImage/Avif.tsx b/packages/example/src/AnimatedImage/Avif.tsx
new file mode 100644
index 0000000000..68fb817585
--- /dev/null
+++ b/packages/example/src/AnimatedImage/Avif.tsx
@@ -0,0 +1,7 @@
+import {AnimatedImage} from 'remotion';
+
+export const AvifAnimatedImage = () => {
+ return (
+ <AnimatedImage src="https://colinbendell.github.io/webperf/animated-gif-decode/2.avif" />
+ );
+};
diff --git a/packages/example/src/AnimatedImage/Gif.tsx b/packages/example/src/AnimatedImage/Gif.tsx
new file mode 100644
index 0000000000..7fe90b3582
--- /dev/null
+++ b/packages/example/src/AnimatedImage/Gif.tsx
@@ -0,0 +1,7 @@
+import {AnimatedImage} from 'remotion';
+
+export const GifAnimatedImage = () => {
+ return (
+ <AnimatedImage src="https://gist.github.com/nolanlawson/73f15f3fe612b8770e79/raw/be4205effd089b38ccd197de544e6370785f6b5e/chopsticks.gif" />
+ );
+};
diff --git a/packages/example/src/AnimatedImage/Webp.tsx b/packages/example/src/AnimatedImage/Webp.tsx
new file mode 100644
index 0000000000..632974ad19
--- /dev/null
+++ b/packages/example/src/AnimatedImage/Webp.tsx
@@ -0,0 +1,7 @@
+import {AnimatedImage} from 'remotion';
+
+export const WebpAnimatedImage = () => {
+ return (
+ <AnimatedImage src="https://mathiasbynens.be/demo/animated-webp-supported.webp" />
+ );
+};
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index 81418d573b..f2df41fd78 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -106,6 +106,9 @@ if (alias !== 'alias') {
const INCLUDE_COMP_BREAKING_GET_COMPOSITIONS = false;
+import {AvifAnimatedImage} from './AnimatedImage/Avif';
+import {GifAnimatedImage} from './AnimatedImage/Gif';
+import {WebpAnimatedImage} from './AnimatedImage/Webp';
// @ts-expect-error no types
import styles from './styles.module.scss';
import {VideoParser} from './VideoParser';
@@ -706,6 +709,32 @@ export const Index: React.FC = () => {
durationInFrames={100}
/>
</Folder>
+ <Folder name="AnimatedImage">
+ <Composition
+ id="gif-animated-image"
+ component={GifAnimatedImage}
+ width={1920}
+ height={1080}
+ durationInFrames={200}
+ fps={30}
+ />
+ <Composition
+ id="avif-animated-image"
+ component={AvifAnimatedImage}
+ width={1920}
+ height={1080}
+ durationInFrames={200}
+ fps={30}
+ />
+ <Composition
+ id="webp-animated-image"
+ component={WebpAnimatedImage}
+ width={1920}
+ height={1080}
+ durationInFrames={200}
+ fps={30}
+ />
+ </Folder>
<Folder name="still-tests">
<Still
id="still-zoom"