Skip to content

🎥 Make videos programmatically with React

Update OffthreadRemoteVideo.tsx

Jonny Burger588438e3427d
diff --git a/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx b/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx
index e7d7558819..bd134b1c96 100644
--- a/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx
+++ b/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx
@@ -1,4 +1,4 @@
-import {parseMedia} from '@remotion/media-parser';
+import {getVideoMetadata} from '@remotion/media-utils';
import {StudioInternals} from '@remotion/studio';
import {CalculateMetadataFunction, OffthreadVideo, staticFile} from 'remotion';
@@ -8,22 +8,14 @@ const src = staticFile('bigbuckbunny.mp4') + '#t=lol';
export const calculateMetadataFn: CalculateMetadataFunction<
Record<string, unknown>
> = async () => {
- const {slowDurationInSeconds, dimensions} = await parseMedia({
- src,
- fields: {
- dimensions: true,
- slowDurationInSeconds: true,
- },
- });
- if (dimensions === null) {
- throw new Error('No video track');
- }
+ const {durationInSeconds, width, height} = await getVideoMetadata(src);
+ console.log({durationInSeconds});
return {
- durationInFrames: Math.round(slowDurationInSeconds * fps),
+ durationInFrames: Math.round(durationInSeconds * fps),
fps,
- width: Math.floor(dimensions.width / 2) * 2,
- height: Math.floor(dimensions.height / 2) * 2,
+ width: Math.floor(width / 2) * 2,
+ height: Math.floor(height / 2) * 2,
};
};