Skip to content

🎥 Make videos programmatically with React

add offthread example videos

Jonny Burgerf63a45d3cadd
diff --git a/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx b/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx
new file mode 100644
index 0000000000..9e57edd374
--- /dev/null
+++ b/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx
@@ -0,0 +1,12 @@
+import {interpolate, OffthreadVideo} from 'remotion';
+
+export const OffthreadRemoteVideo: React.FC = () => {
+ return (
+ <OffthreadVideo
+ volume={(f) =>
+ interpolate(f, [0, 500], [1, 0], {extrapolateRight: 'clamp'})
+ }
+ src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
+ />
+ );
+};
diff --git a/packages/example/src/RemoteVideo/index.tsx b/packages/example/src/RemoteVideo/index.tsx
index 1831df0c1b..6ed00fd38a 100644
--- a/packages/example/src/RemoteVideo/index.tsx
+++ b/packages/example/src/RemoteVideo/index.tsx
@@ -1,8 +1,8 @@
-import {interpolate, OffthreadVideo} from 'remotion';
+import {interpolate, Video} from 'remotion';
const RemoteVideo: React.FC = () => {
return (
- <OffthreadVideo
+ <Video
volume={(f) =>
interpolate(f, [0, 500], [1, 0], {extrapolateRight: 'clamp'})
}
diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsx
index 3b8a484302..4ae90df43a 100644
--- a/packages/example/src/Video.tsx
+++ b/packages/example/src/Video.tsx
@@ -7,6 +7,7 @@ import {FontDemo} from './Fonts';
import {Framer} from './Framer';
import {FreezeExample} from './Freeze/FreezeExample';
import {MissingImg} from './MissingImg';
+import {OffthreadRemoteVideo} from './OffthreadRemoteVideo/OffthreadRemoteVideo';
import {OrbScene} from './Orb';
import InfinityVideo from './ReallyLongVideo';
import RemoteVideo from './RemoteVideo';
@@ -61,7 +62,6 @@ export const Index: React.FC = () => {
fps={30}
durationInFrames={100}
/>
-
<Composition
id="freeze-example"
component={FreezeExample}
@@ -180,6 +180,14 @@ export const Index: React.FC = () => {
codec: 'mp4' as const,
}}
/>
+ <Composition
+ id="OffthreadRemoteVideo"
+ component={OffthreadRemoteVideo}
+ width={1080}
+ height={1080}
+ fps={30}
+ durationInFrames={100}
+ />
<Composition
id="video-testing-webm"
component={VideoTesting}
diff --git a/packages/renderer/src/offthread-video-server.ts b/packages/renderer/src/offthread-video-server.ts
index 797c9dad2e..c2aabca2a6 100644
--- a/packages/renderer/src/offthread-video-server.ts
+++ b/packages/renderer/src/offthread-video-server.ts
@@ -70,9 +70,14 @@ export const startOffthreadVideoServer = (
}
res.writeHead(200);
- readable.pipe(res).on('close', () => {
- res.end();
- });
+ readable
+ .pipe(res)
+ .on('close', () => {
+ res.end();
+ })
+ .on('error', (err) => {
+ onError(err);
+ });
})
.catch((err) => {
res.writeHead(500);