Skip to content

🎥 Make videos programmatically with React

Internal: Add build-fast without legacy media packages

Jonny Burger712f99315348
diff --git a/bun.lock b/bun.lock
index dac85b5b8e..58e1daccb8 100644
--- a/bun.lock
+++ b/bun.lock
@@ -210,7 +210,6 @@
"name": "@remotion/bundler",
"version": "4.0.534",
"dependencies": {
- "@remotion/media-parser": "workspace:*",
"@remotion/studio": "workspace:*",
"@remotion/studio-shared": "workspace:*",
"@remotion/timeline-utils": "workspace:*",
@@ -846,7 +845,6 @@
"@remotion/mac-cursors": "workspace:*",
"@remotion/maptiler": "workspace:*",
"@remotion/media": "workspace:*",
- "@remotion/media-parser": "workspace:*",
"@remotion/media-utils": "workspace:*",
"@remotion/motion-blur": "workspace:*",
"@remotion/noise": "workspace:*",
@@ -868,7 +866,6 @@
"@remotion/tailwind-v4": "workspace:*",
"@remotion/three": "workspace:*",
"@remotion/transitions": "workspace:*",
- "@remotion/webcodecs": "workspace:*",
"@remotion/whisper-web": "workspace:*",
"@remotion/zod-types": "workspace:*",
"@remotion/zod-types-v3": "workspace:*",
diff --git a/package.json b/package.json
index 9ad66b660a..c3548f28d3 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,7 @@
"formatting": "turbo run formatting --no-update-notifier",
"format": "bun pre-commit.ts",
"build": "turbo run make --no-update-notifier",
+ "build-fast": "turbo run make --filter='!@remotion/media-parser' --filter='!@remotion/webcodecs' --filter='!docs' --filter='!@remotion/it-tests' --no-update-notifier",
"build-docs": "TURBO_TELEMETRY_DISABLED=1 turbo run build-docs --no-update-notifier",
"testssr": "turbo run testssr --no-update-notifier",
"testmonorepo": "turbo run testmonorepo --no-update-notifier",
diff --git a/packages/bundler/package.json b/packages/bundler/package.json
index 37a308136b..bb5666a15e 100644
--- a/packages/bundler/package.json
+++ b/packages/bundler/package.json
@@ -28,7 +28,6 @@
"@remotion/studio": "workspace:*",
"@remotion/studio-shared": "workspace:*",
"@remotion/timeline-utils": "workspace:*",
- "@remotion/media-parser": "workspace:*",
"style-loader": "4.0.0",
"webpack": "5.105.0"
},
diff --git a/packages/bundler/src/shared-bundler-config.ts b/packages/bundler/src/shared-bundler-config.ts
index c20a6d911c..cfb860f89f 100644
--- a/packages/bundler/src/shared-bundler-config.ts
+++ b/packages/bundler/src/shared-bundler-config.ts
@@ -59,16 +59,6 @@ export const getResolveConfig = () => ({
'index.mjs',
),
- ...(NoReactInternals.ENABLE_V5_BREAKING_CHANGES
- ? {}
- : {
- '@remotion/media-parser/worker': path.resolve(
- require.resolve('@remotion/media-parser'),
- '..',
- 'esm',
- 'worker.mjs',
- ),
- }),
// Studio entry points are also passed to the bundler as resolved CJS paths.
// Route both those paths and package imports through the same ESM build.
...Object.fromEntries(
diff --git a/packages/convert/tsconfig.json b/packages/convert/tsconfig.json
index 60cb297df0..2d53b3158a 100644
--- a/packages/convert/tsconfig.json
+++ b/packages/convert/tsconfig.json
@@ -39,12 +39,6 @@
"noEmit": true
},
"references": [
- {
- "path": "../media-parser"
- },
- {
- "path": "../webcodecs"
- },
{
"path": "../design"
}
diff --git a/packages/example/package.json b/packages/example/package.json
index 235128a501..8ca7695302 100644
--- a/packages/example/package.json
+++ b/packages/example/package.json
@@ -63,7 +63,6 @@
"@remotion/starburst": "workspace:*",
"@remotion/lottie": "workspace:*",
"@remotion/media": "workspace:*",
- "@remotion/media-parser": "workspace:*",
"@remotion/media-utils": "workspace:*",
"@remotion/motion-blur": "workspace:*",
"@remotion/noise": "workspace:*",
@@ -82,7 +81,6 @@
"@remotion/tailwind-v4": "workspace:*",
"@remotion/three": "workspace:*",
"@remotion/transitions": "workspace:*",
- "@remotion/webcodecs": "workspace:*",
"@remotion/whisper-web": "workspace:*",
"@remotion/zod-types": "workspace:*",
"@remotion/zod-types-v3": "workspace:*",
diff --git a/packages/example/src/Encoder/SrcEncoder.tsx b/packages/example/src/Encoder/SrcEncoder.tsx
index d4069ef2f7..5755ce0952 100644
--- a/packages/example/src/Encoder/SrcEncoder.tsx
+++ b/packages/example/src/Encoder/SrcEncoder.tsx
@@ -1,13 +1,14 @@
-import {MediaParserVideoTrack} from '@remotion/media-parser';
import {
- ConvertMediaProgress,
- convertMedia,
- webcodecsController,
-} from '@remotion/webcodecs';
-import React, {useCallback, useRef, useState} from 'react';
-import {flushSync} from 'react-dom';
+ ALL_FORMATS,
+ BufferTarget,
+ Conversion,
+ Input,
+ Output,
+ UrlSource,
+ WebMOutputFormat,
+} from 'mediabunny';
+import React, {useCallback, useEffect, useRef, useState} from 'react';
import {AbsoluteFill} from 'remotion';
-import {fitElementSizeInContainer} from './fit-element-size-in-container';
const CANVAS_WIDTH = 1024 / 4;
const CANVAS_HEIGHT = (CANVAS_WIDTH / 16) * 9;
@@ -52,129 +53,125 @@ export const SrcEncoder: React.FC<{
readonly src: string;
readonly label: string;
}> = ({src, label}) => {
- const [state, setState] = useState<ConvertMediaProgress>({
+ const [state, setState] = useState({
decodedAudioFrames: 0,
decodedVideoFrames: 0,
- encodedVideoFrames: 0,
- encodedAudioFrames: 0,
- bytesWritten: 0,
- millisecondsWritten: 0,
- expectedOutputDurationInMs: null,
- overallProgress: null,
+ overallProgress: 0,
});
const [downloadFn, setDownloadFn] = useState<null | (() => void)>(null);
const [abortfn, setAbortFn] = useState<null | (() => void)>(null);
const [error, setError] = useState<Error | null>(null);
-
+ const abortRef = useRef<null | (() => void)>(null);
const ref = useRef<HTMLCanvasElement>(null);
- const i = useRef(0);
-
- const onVideoFrame = useCallback(
- async ({
- frame,
- track,
- }: {
- frame: VideoFrame;
- track: MediaParserVideoTrack;
- }) => {
- i.current++;
-
- if (i.current % 10 === 1) {
- const rotatedWidth =
- track.rotation === -90 || track.rotation === 90
- ? CANVAS_HEIGHT
- : CANVAS_WIDTH;
- const rotatedHeight =
- track.rotation === -90 || track.rotation === 90
- ? CANVAS_WIDTH
- : CANVAS_HEIGHT;
-
- const fitted = fitElementSizeInContainer({
- containerSize: {
- width: rotatedWidth,
- height: rotatedHeight,
- },
- elementSize: {
- width: track.displayAspectWidth,
- height: track.displayAspectHeight,
- },
- });
-
- const image = await createImageBitmap(frame, {
- resizeHeight: fitted.height * 2,
- resizeWidth: fitted.width * 2,
- });
+ useEffect(() => {
+ return () => abortRef.current?.();
+ }, [src]);
- if (!ref.current) {
- return frame;
- }
-
- const context = ref.current.getContext('2d');
- if (!context) {
- return frame;
- }
- ref.current.width = CANVAS_WIDTH;
- ref.current.height = CANVAS_HEIGHT;
+ const onClick = useCallback(async () => {
+ if (abortRef.current) {
+ return;
+ }
- if (track.rotation === -90) {
- context.rotate((-track.rotation * Math.PI) / 180);
- context.drawImage(
- image,
- fitted.left,
- -CANVAS_WIDTH / 2 - fitted.height / 2,
- fitted.width,
- fitted.height,
- );
- context.setTransform(1, 0, 0, 1, 0, 0);
- }
- // TODO: Implement 90 and 180 rotations
- else {
- context.drawImage(image, fitted.left, 0, fitted.width, fitted.height);
- }
+ const input = new Input({
+ formats: ALL_FORMATS,
+ source: new UrlSource(src),
+ });
+ const output = new Output({
+ format: new WebMOutputFormat(),
+ target: new BufferTarget(),
+ });
+ let conversion: Conversion | null = null;
+ let cancelled = false;
+ const abort = () => {
+ cancelled = true;
+ if (conversion) {
+ void conversion.cancel();
+ } else {
+ input.dispose();
}
+ };
+ abortRef.current = abort;
+ setAbortFn(() => abort);
+ setError(null);
+ setDownloadFn(null);
+ const progress = {
+ decodedAudioFrames: 0,
+ decodedVideoFrames: 0,
+ overallProgress: 0,
+ };
+ setState({...progress});
- return frame;
- },
- [],
- );
-
- const onClick = useCallback(async () => {
try {
- const abortController = webcodecsController();
- setAbortFn(() => () => abortController.abort());
- const fn = await convertMedia({
- src,
- onVideoFrame,
- onProgress: (s) => {
- flushSync(() => {
- setState(() => s);
- });
+ conversion = await Conversion.init({
+ input,
+ output,
+ video: {
+ codec: 'vp9',
+ forceTranscode: true,
+ process: (sample) => {
+ progress.decodedVideoFrames++;
+ const context = ref.current?.getContext('2d');
+ if (context && progress.decodedVideoFrames % 10 === 1) {
+ context.clearRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
+ sample.drawWithFit(context, {fit: 'contain'});
+ }
+ return sample;
+ },
+ },
+ audio: {
+ codec: 'opus',
+ forceTranscode: true,
+ process: (sample) => {
+ progress.decodedAudioFrames++;
+ return sample;
+ },
},
- videoCodec: 'vp9',
- audioCodec: 'opus',
- container: 'webm',
- controller: abortController,
});
- setDownloadFn(() => {
- return async () => {
- const file = await fn.save();
- const a = document.createElement('a');
- a.href = URL.createObjectURL(file);
- a.download = 'hithere';
- a.click();
-
- setTimeout(() => {
- fn.remove();
- }, 1000);
- };
+ if (cancelled) {
+ return;
+ }
+ if (!conversion.isValid) {
+ throw new Error('Cannot convert this file to WebM in this browser');
+ }
+ conversion.onProgress = (overallProgress) => {
+ progress.overallProgress = overallProgress;
+ setState({...progress});
+ };
+ await conversion.execute();
+ const buffer = output.target.buffer;
+ if (!buffer) {
+ throw new Error('Conversion produced no output');
+ }
+ setState({...progress, overallProgress: 1});
+ const file = new Blob([buffer], {type: 'video/webm'});
+ setDownloadFn(() => () => {
+ const a = document.createElement('a');
+ const url = URL.createObjectURL(file);
+ a.href = url;
+ a.download = 'converted.webm';
+ a.click();
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
});
} catch (err) {
- console.log(err);
- setError(err as Error);
+ if (!cancelled) {
+ setError(err as Error);
+ }
+ } finally {
+ try {
+ if (conversion && conversion.state !== 'canceled') {
+ await conversion.cancel();
+ } else {
+ await output.cancel();
+ }
+ } finally {
+ input.dispose();
+ abortRef.current = null;
+ setAbortFn(null);
+ }
}
- }, [onVideoFrame, src]);
+ }, [src]);
return (
<div
@@ -248,9 +245,11 @@ export const SrcEncoder: React.FC<{
}}
>
<SampleCount count={state.decodedVideoFrames} label="VD" />
- <SampleCount count={state.encodedVideoFrames} label="VE" />
<SampleCount count={state.decodedAudioFrames} label="AD" />
- <SampleCount count={state.encodedAudioFrames} label="AE" />
+ <SampleCount
+ count={Math.round(state.overallProgress * 100)}
+ label="%"
+ />
<br />
</div>
</AbsoluteFill>
diff --git a/packages/example/src/Encoder/fit-element-size-in-container.ts b/packages/example/src/Encoder/fit-element-size-in-container.ts
deleted file mode 100644
index b90da2002d..0000000000
--- a/packages/example/src/Encoder/fit-element-size-in-container.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import type {Dimensions} from '@remotion/layout-utils';
-
-type Rect = {
- width: number;
- height: number;
- top: number;
- left: number;
-};
-
-// Resize an aspect ratio to fit into a container
-// and center it
-export const fitElementSizeInContainer = ({
- containerSize,
- elementSize,
-}: {
- containerSize: Dimensions;
- elementSize: Dimensions;
-}): Rect => {
- const heightRatio = containerSize.height / elementSize.height;
- const widthRatio = containerSize.width / elementSize.width;
-
- const ratio = Math.min(heightRatio, widthRatio);
-
- const newWidth = elementSize.width * ratio;
- const newHeight = elementSize.height * ratio;
-
- if (
- newWidth > containerSize.width + 0.000001 ||
- newHeight > containerSize.height + 0.000001
- ) {
- throw new Error(
- `Element is too big to fit into the container. Max size: ${containerSize.width}x${containerSize.height}, element size: ${newWidth}x${newHeight}`,
- );
- }
-
- return {
- width: newWidth,
- height: newHeight,
- top: (containerSize.height - newHeight) / 2,
- left: (containerSize.width - newWidth) / 2,
- };
-};
diff --git a/packages/example/src/LoopedOffthreadVideo.tsx b/packages/example/src/LoopedOffthreadVideo.tsx
index 636374a48b..1d3bf0caa1 100644
--- a/packages/example/src/LoopedOffthreadVideo.tsx
+++ b/packages/example/src/LoopedOffthreadVideo.tsx
@@ -1,4 +1,4 @@
-import {mediaParserController, parseMedia} from '@remotion/media-parser';
+import {ALL_FORMATS, Input, UrlSource} from 'mediabunny';
import React, {useEffect, useState} from 'react';
import {
cancelRender,
@@ -18,27 +18,32 @@ const LoopedOffthreadVideo: React.FC<RemotionOffthreadVideoProps> = (props) => {
const {fps} = useVideoConfig();
useEffect(() => {
- const controller = mediaParserController();
+ const input = new Input({
+ formats: ALL_FORMATS,
+ source: new UrlSource(props.src),
+ });
+ let cancelled = false;
- parseMedia({
- src: props.src,
- acknowledgeRemotionLicense: true,
- controller,
- fields: {
- slowDurationInSeconds: true,
- },
- })
- .then(({slowDurationInSeconds}) => {
- setDuration(slowDurationInSeconds);
+ input
+ .computeDuration()
+ .then((durationInSeconds) => {
+ if (cancelled) {
+ return;
+ }
+ setDuration(durationInSeconds);
continueRender(handle);
})
.catch((err) => {
- cancelRender(err);
- });
+ if (!cancelled) {
+ cancelRender(err);
+ }
+ })
+ .finally(() => input.dispose());
return () => {
+ cancelled = true;
continueRender(handle);
- controller.abort();
+ input.dispose();
};
}, [handle, props.src]);
diff --git a/packages/example/src/OffthreadRemoteVideo/MultiChannelAudio.tsx b/packages/example/src/OffthreadRemoteVideo/MultiChannelAudio.tsx
index f98c1aac82..16bac3d90e 100644
--- a/packages/example/src/OffthreadRemoteVideo/MultiChannelAudio.tsx
+++ b/packages/example/src/OffthreadRemoteVideo/MultiChannelAudio.tsx
@@ -1,6 +1,6 @@
-import {parseMedia} from '@remotion/media-parser';
import {StudioInternals} from '@remotion/studio';
import {CalculateMetadataFunction, Html5Audio} from 'remotion';
+import {getMediaMetadata} from '../get-media-metadata';
const fps = 30;
const src = 'https://remotion.media/multiple-audio-streams.mov';
@@ -8,16 +8,10 @@ const src = 'https://remotion.media/multiple-audio-streams.mov';
export const calculateMetadataFn: CalculateMetadataFunction<
Record<string, unknown>
> = async () => {
- const {slowDurationInSeconds} = await parseMedia({
- src,
- acknowledgeRemotionLicense: true,
- fields: {
- slowDurationInSeconds: true,
- },
- });
+ const {durationInSeconds} = await getMediaMetadata(src);
return {
- durationInFrames: Math.round(slowDurationInSeconds * fps),
+ durationInFrames: Math.round(durationInSeconds * fps),
fps,
};
};
diff --git a/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteSeries.tsx b/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteSeries.tsx
index e44eedcb05..b5a9dc3bba 100644
--- a/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteSeries.tsx
+++ b/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteSeries.tsx
@@ -1,6 +1,6 @@
-import {parseMedia} from '@remotion/media-parser';
import {StudioInternals} from '@remotion/studio';
import {CalculateMetadataFunction, OffthreadVideo, Series} from 'remotion';
+import {getMediaMetadata} from '../get-media-metadata';
const fps = 30;
const sources = [
@@ -17,24 +17,17 @@ export const calculateMetadataFn: CalculateMetadataFunction<
> = async () => {
const all = await Promise.all(
sources.map(async (src) => {
- const {slowDurationInSeconds, dimensions} = await parseMedia({
- src,
- acknowledgeRemotionLicense: true,
- fields: {
- slowDurationInSeconds: true,
- dimensions: true,
- },
- });
+ const {durationInSeconds, dimensions} = await getMediaMetadata(src);
return {
src,
- slowDurationInSeconds,
+ durationInSeconds,
dimensions,
};
}),
);
const allDurations = all
- .map((a) => a.slowDurationInSeconds)
+ .map((a) => a.durationInSeconds)
.reduce((a, b) => a + b, 0);
// get biggest dimension
const biggestDimension = all.reduce((a, b) => {
@@ -57,7 +50,7 @@ export const calculateMetadataFn: CalculateMetadataFunction<
width: Math.floor(biggestDimension.dimensions!.width / 2) * 2,
height: Math.floor(biggestDimension.dimensions!.height / 2) * 2,
props: {
- durations: all.map((a) => a.slowDurationInSeconds),
+ durations: all.map((a) => a.durationInSeconds),
},
};
};
diff --git a/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx b/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx
index cc638f6cbd..2d33c1b448 100644
--- a/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx
+++ b/packages/example/src/OffthreadRemoteVideo/OffthreadRemoteVideo.tsx
@@ -1,6 +1,6 @@
-import {parseMedia} from '@remotion/media-parser';
import {StudioInternals} from '@remotion/studio';
import {CalculateMetadataFunction, OffthreadVideo} from 'remotion';
+import {getMediaMetadata} from '../get-media-metadata';
const fps = 30;
const src = 'https://remotion.media/bigbuckbunny.mp4#t=lol';
@@ -8,21 +8,14 @@ const src = 'https://remotion.media/bigbuckbunny.mp4#t=lol';
export const calculateMetadataFn: CalculateMetadataFunction<
Record<string, unknown>
> = async () => {
- const {slowDurationInSeconds, dimensions} = await parseMedia({
- src,
- acknowledgeRemotionLicense: true,
- fields: {
- slowDurationInSeconds: true,
- dimensions: true,
- },
- });
+ const {durationInSeconds, dimensions} = await getMediaMetadata(src);
if (dimensions === null) {
throw new Error('Dimensions are null');
}
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,
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index a7df6d5e80..279b1a8573 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -200,7 +200,6 @@ import {
import {VariableGoogleFont} from './VariableGoogleFont/VariableGoogleFont';
import {VideoOnCanvas} from './VideoOnCanvas';
import {Greenscreen} from './VideoOnCanvas/greenscreen';
-import {VideoParser} from './VideoParser';
import {VideoSpeed} from './VideoSpeed';
import {
VideoTesting,
@@ -222,7 +221,6 @@ if (alias !== 'alias') {
const INCLUDE_COMP_BREAKING_GET_COMPOSITIONS = false;
-import {parseMedia} from '@remotion/media-parser';
import {zMatrix} from '@remotion/zod-types';
import {ThreeDContext} from './3DContext';
import {ThreeDSvgContent} from './3DSvgContent';
@@ -264,6 +262,7 @@ import {RadialProgressiveBlurTest} from './EffectsTestbed/RadialProgressiveBlur'
import {TearTest} from './EffectsTestbed/Tear';
import {VideoEffectsFastRefresh} from './EffectsTestbed/VideoEffectsFastRefresh';
import {Empty} from './Empty';
+import {getMediaMetadata} from './get-media-metadata';
import {
Issue8974IndependentVideosTimeline,
Issue8974SeriesTimeline,
@@ -1136,16 +1135,13 @@ export const Index: React.FC = () => {
calculateMetadata={async ({props}) => {
const fps = 30;
- const {slowDurationInSeconds} = await parseMedia({
- src: props.src as string,
- fields: {
- slowDurationInSeconds: true,
- },
- });
+ const {durationInSeconds} = await getMediaMetadata(
+ props.src as string,
+ );
return {
props: props,
- durationInFrames: Math.round(slowDurationInSeconds * fps),
+ durationInFrames: Math.round(durationInSeconds * fps),
fps,
width: 800,
height: 800,
@@ -2729,16 +2725,6 @@ export const Index: React.FC = () => {
durationInFrames={10_000}
/>
</Folder>
- <Folder name="VideoParser">
- <Composition
- id="VideoParser"
- component={VideoParser}
- fps={30}
- height={1080}
- width={1080}
- durationInFrames={10_000}
- />
- </Folder>
<Still
id="DecoderDemo"
component={DecoderDemo}
diff --git a/packages/example/src/VideoParser/index.tsx b/packages/example/src/VideoParser/index.tsx
deleted file mode 100644
index 1d8ad571f6..0000000000
--- a/packages/example/src/VideoParser/index.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import {parseMedia} from '@remotion/media-parser';
-import {getVideoMetadata} from '@remotion/media-utils';
-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({
- src: 'https://upload.wikimedia.org/wikipedia/commons/transcoded/c/c0/Big_Buck_Bunny_4K.webm/Big_Buck_Bunny_4K.webm.720p.vp9.webm',
- fields: {
- durationInSeconds: true,
- dimensions: true,
- },
- }).then(({durationInSeconds, dimensions}) => {
- console.log(
- '@remotion/media-parser',
- durationInSeconds,
- dimensions,
- 'in ',
- Date.now() - start,
- 'ms',
- );
- });
-
- getVideoMetadata(src).then(({durationInSeconds}) => {
- console.log(
- 'getVideoMetadata',
- durationInSeconds,
- 'in ',
- Date.now() - start,
- 'ms',
- );
- });
- }, []);
-
- return <div>VideoParser</div>;
-};
diff --git a/packages/example/src/get-media-metadata.ts b/packages/example/src/get-media-metadata.ts
index 7a8a362597..6abaa74480 100644
--- a/packages/example/src/get-media-metadata.ts
+++ b/packages/example/src/get-media-metadata.ts
@@ -23,22 +23,26 @@ export const getMediaMetadata = async (src: string) => {
source: new UrlSource(src),
});
- const durationInSeconds = await input.computeDuration();
- const videoTrack = await input.getPrimaryVideoTrack();
- const dimensions = videoTrack
- ? {
- width: await videoTrack.getDisplayWidth(),
- height: await videoTrack.getDisplayHeight(),
- }
- : null;
- const packetStats = await videoTrack?.computePacketStats(50);
- const fps = packetStats
- ? snapToCommonFps(packetStats.averagePacketRate)
- : null;
+ try {
+ const durationInSeconds = await input.computeDuration();
+ const videoTrack = await input.getPrimaryVideoTrack();
+ const dimensions = videoTrack
+ ? {
+ width: await videoTrack.getDisplayWidth(),
+ height: await videoTrack.getDisplayHeight(),
+ }
+ : null;
+ const packetStats = await videoTrack?.computePacketStats(50);
+ const fps = packetStats
+ ? snapToCommonFps(packetStats.averagePacketRate)
+ : null;
- return {
- durationInSeconds,
- dimensions,
- fps,
- };
+ return {
+ durationInSeconds,
+ dimensions,
+ fps,
+ };
+ } finally {
+ input.dispose();
+ }
};
diff --git a/packages/example/tsconfig.json b/packages/example/tsconfig.json
index 0e2830b518..9da15740d8 100644
--- a/packages/example/tsconfig.json
+++ b/packages/example/tsconfig.json
@@ -39,8 +39,6 @@
{"path": "../zod-types"},
{"path": "../zod-types-v3"},
{"path": "../svg-3d-engine"},
- {"path": "../media-parser"},
- {"path": "../webcodecs"},
{"path": "../whisper-web"},
{"path": "../studio-protocol"},
{"path": "../light-leaks"},
diff --git a/packages/studio/tsconfig.json b/packages/studio/tsconfig.json
index 2995bde0f9..5436c7e633 100644
--- a/packages/studio/tsconfig.json
+++ b/packages/studio/tsconfig.json
@@ -33,9 +33,6 @@
{
"path": "../renderer"
},
- {
- "path": "../webcodecs"
- },
{
"path": "../player"
},