🎥 Make videos programmatically with React
client side info
Jonny Burger71147aea2bee
diff --git a/packages/example/src/VideoParser/index.tsx b/packages/example/src/VideoParser/index.tsxindex 0a4a72bd6f..13c34d3818 100644--- a/packages/example/src/VideoParser/index.tsx+++ b/packages/example/src/VideoParser/index.tsx@@ -1,27 +1,28 @@+import {getVideoMetadata} from '@remotion/media-utils';import {parseMedia} from '@remotion/video-parser';import {useEffect} from 'react';+import {staticFile} from 'remotion';++const src = staticFile('blush-2x.mp4');export const VideoParser: React.FC = () => {useEffect(() => {const start = Date.now();- parseMedia(- 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',- {- durationInSeconds: true,- },- ).then(({durationInSeconds}) => {+ parseMedia(src, {+ durationInSeconds: true,+ dimensions: true,+ }).then(({durationInSeconds, dimensions}) => {console.log('@remotion/video-parser',durationInSeconds,+ dimensions,'in ',Date.now() - start,'ms',);});- /*- GetVideoMetadata(- 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',- ).then(({durationInSeconds}) => {++ getVideoMetadata(src).then(({durationInSeconds}) => {console.log('getVideoMetadata',durationInSeconds,@@ -30,7 +31,6 @@ export const VideoParser: React.FC = () => {'ms',);});- */}, []);return <div>VideoParser</div>;diff --git a/packages/video-parser/src/from-web.ts b/packages/video-parser/src/from-web.tsindex dc594e75d8..6aa3739bfd 100644--- a/packages/video-parser/src/from-web.ts+++ b/packages/video-parser/src/from-web.ts@@ -2,16 +2,24 @@ import type {ReaderInterface} from './reader';export const webReader: ReaderInterface = {read: async (src, range) => {- if (!src.startsWith('https://') && !src.startsWith('http://')) {+ const resolvedUrl =+ typeof window !== 'undefined' && typeof window.location !== 'undefined'+ ? new URL(src, window.location.origin).toString()+ : src;++ if (+ !resolvedUrl.startsWith('https://') &&+ !resolvedUrl.startsWith('http://')+ ) {return Promise.reject(new Error(- src ++ resolvedUrl +' is not a URL - needs to start with http:// or https://. If you want to read a local file, pass `nodeReader` to getVideoMetadata().',),);}- const res = await fetch(src, {+ const res = await fetch(resolvedUrl, {headers:range === null? {}