🎥 Make videos programmatically with React
Update OffthreadRemoteVideo.tsx
Jonny Burger3ab3d23031f1
diff --git a/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx b/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsxindex 5bb28d5420..048e495a85 100644--- a/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx+++ b/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx@@ -1,4 +1,4 @@-import {getVideoMetadata} from '@remotion/media-utils';+import {parseMedia} from '@remotion/media-parser';import {StudioInternals} from '@remotion/studio';import {AbsoluteFill,@@ -14,13 +14,22 @@ const src = staticFile('bigbuckbunny.mp4');export const calculateMetadataFn: CalculateMetadataFunction<Record<string, unknown>> = async () => {- const {durationInSeconds, width, height} = await getVideoMetadata(src);+ const {slowDurationInSeconds, dimensions} = await parseMedia({+ src,+ fields: {+ dimensions: true,+ slowDurationInSeconds: true,+ },+ });+ if (dimensions === null) {+ throw new Error('No video track');+ }return {- durationInFrames: Math.round(durationInSeconds * fps),+ durationInFrames: Math.round(slowDurationInSeconds * fps),fps,- width: Math.floor(width / 2) * 2,- height: Math.floor(height / 2) * 2,+ width: Math.floor(dimensions.width / 2) * 2,+ height: Math.floor(dimensions.height / 2) * 2,};};