Skip to content

🎥 Make videos programmatically with React

progress

JonnyBurger14d5c176bd8a
diff --git a/packages/convert/app/components/AudioCodecSelection.tsx b/packages/convert/app/components/AudioCodecSelection.tsx
index 8068d5f982..ebab960c9b 100644
--- a/packages/convert/app/components/AudioCodecSelection.tsx
+++ b/packages/convert/app/components/AudioCodecSelection.tsx
@@ -1,7 +1,6 @@
-import type {MediaParserAudioCodec} from '@remotion/media-parser';
-import type {AudioOperation} from '@remotion/webcodecs';
import type {InputAudioTrack} from 'mediabunny';
import React from 'react';
+import type {AudioOperation} from '~/lib/audio-operation';
import {getAudioOperationId} from '~/lib/operation-key';
import {AudioCodecDropWarning} from './AudioCodecDropWarning';
import {AudioOperationOption} from './AudioOperationOption';
@@ -18,10 +17,7 @@ export const AudioCodecSelection: React.FC<{
readonly audioTrackOptions: AudioOperation[];
readonly index: string;
readonly setIndex: (v: string) => void;
- readonly currentAudioCodec:
- | InputAudioTrack['codec']
- | MediaParserAudioCodec
- | null;
+ readonly currentAudioCodec: InputAudioTrack['codec'];
}> = ({audioTrackOptions, index, setIndex, currentAudioCodec}) => {
if (!currentAudioCodec) {
throw new Error('No current audio codec, should not render this component');
diff --git a/packages/convert/app/components/AudioOperationOption.tsx b/packages/convert/app/components/AudioOperationOption.tsx
index 1df687cbc1..612cb5de54 100644
--- a/packages/convert/app/components/AudioOperationOption.tsx
+++ b/packages/convert/app/components/AudioOperationOption.tsx
@@ -1,14 +1,10 @@
-import type {MediaParserAudioCodec} from '@remotion/media-parser';
-import type {AudioOperation, ConvertMediaAudioCodec} from '@remotion/webcodecs';
import type {InputAudioTrack} from 'mediabunny';
+import type {AudioOperation} from '~/lib/audio-operation';
import {renderHumanReadableAudioCodec} from '~/lib/render-codec-label';
export const AudioOperationOption: React.FC<{
readonly operation: AudioOperation;
- readonly currentAudioCodec:
- | InputAudioTrack['codec']
- | MediaParserAudioCodec
- | ConvertMediaAudioCodec;
+ readonly currentAudioCodec: InputAudioTrack['codec'];
}> = ({operation, currentAudioCodec}) => {
if (operation.type === 'reencode') {
return renderHumanReadableAudioCodec(operation.audioCodec);
diff --git a/packages/convert/app/components/ConvertForm.tsx b/packages/convert/app/components/ConvertForm.tsx
index 8a25796943..6feb6aa4ed 100644
--- a/packages/convert/app/components/ConvertForm.tsx
+++ b/packages/convert/app/components/ConvertForm.tsx
@@ -1,8 +1,3 @@
-import type {
- MediaParserAudioCodec,
- MediaParserVideoCodec,
-} from '@remotion/media-parser';
-import {getAvailableContainers} from '@remotion/webcodecs';
import type {InputAudioTrack, InputVideoTrack} from 'mediabunny';
import React from 'react';
import {
@@ -11,7 +6,7 @@ import {
} from '~/lib/get-audio-video-config-index';
import {getAudioOperationId, getVideoOperationId} from '~/lib/operation-key';
import {renderHumanReadableContainer} from '~/lib/render-codec-label';
-import type {OutputContainer} from '~/seo';
+import {outputContainers, type OutputContainer} from '~/seo';
import {AudioCodecSelection} from './AudioCodecSelection';
import type {SupportedConfigs} from './get-supported-configs';
import {SelectionSkeleton} from './SelectionSkeleton';
@@ -35,14 +30,8 @@ export const ConvertForm: React.FC<{
readonly audioConfigIndexSelection: Record<number, string>;
readonly setAudioConfigIndex: (trackId: number, key: string) => void;
readonly setVideoConfigIndex: (trackId: number, key: string) => void;
- readonly currentAudioCodec:
- | InputAudioTrack['codec']
- | MediaParserAudioCodec
- | null;
- readonly currentVideoCodec:
- | InputVideoTrack['codec']
- | MediaParserVideoCodec
- | null;
+ readonly currentAudioCodec: InputAudioTrack['codec'] | null;
+ readonly currentVideoCodec: InputVideoTrack['codec'] | null;
}> = ({
container,
setContainer,
@@ -66,7 +55,7 @@ export const ConvertForm: React.FC<{
<SelectValue placeholder="Select a container" />
</SelectTrigger>
<SelectContent>
- {getAvailableContainers().map((availableContainer) => {
+ {outputContainers.map((availableContainer) => {
return (
<SelectGroup key={availableContainer}>
<SelectItem value={availableContainer}>
diff --git a/packages/convert/app/components/ConvertUi.tsx b/packages/convert/app/components/ConvertUi.tsx
index 8567785220..da1ec578ed 100644
--- a/packages/convert/app/components/ConvertUi.tsx
+++ b/packages/convert/app/components/ConvertUi.tsx
@@ -4,11 +4,8 @@ import type {
MediaParserContainer,
MediaParserDimensions,
MediaParserTrack,
- MediaParserVideoCodec,
} from '@remotion/media-parser';
-import type {WebCodecsController} from '@remotion/webcodecs';
-import {webcodecsController, WebCodecsInternals} from '@remotion/webcodecs';
-import type {Rotation} from 'mediabunny';
+import type {InputVideoTrack, Rotation} from 'mediabunny';
import {
ALL_FORMATS,
BlobSource,
@@ -18,7 +15,7 @@ import {
StreamTarget,
UrlSource,
} from 'mediabunny';
-import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
+import React, {useCallback, useMemo, useState} from 'react';
import {canRotateOrMirror} from '~/lib/can-rotate-or-mirror';
import type {ConvertState, Source} from '~/lib/convert-state';
import type {ConvertSections, RotateOrMirrorState} from '~/lib/default-ui';
@@ -77,7 +74,7 @@ const ConvertUI = ({
readonly src: Source;
readonly setSrc: React.Dispatch<React.SetStateAction<Source | null>>;
readonly currentAudioCodec: MediaParserAudioCodec | null;
- readonly currentVideoCodec: MediaParserVideoCodec | null;
+ readonly currentVideoCodec: InputVideoTrack['codec'] | null;
readonly tracks: MediaParserTrack[] | null;
readonly videoThumbnailRef: React.RefObject<VideoThumbnailRef | null>;
readonly unrotatedDimensions: MediaParserDimensions | null;
@@ -185,8 +182,6 @@ const ConvertUI = ({
}));
}, []);
- const controllerRef = useRef<WebCodecsController | null>(null);
-
const [bars, setBars] = useState<number[]>([]);
const onWaveformBars = useCallback((b: number[]) => {
@@ -194,9 +189,6 @@ const ConvertUI = ({
}, []);
const onClick = useCallback(() => {
- const controller = webcodecsController();
- controllerRef.current = controller;
-
const progress: ConvertProgressType = {
bytesWritten: 0,
millisecondsWritten: 0,
@@ -339,14 +331,6 @@ const ConvertUI = ({
setState({type: 'idle'});
}, []);
- useEffect(() => {
- return () => {
- if (controllerRef.current) {
- controllerRef.current.abort();
- }
- };
- }, []);
-
const onMirrorClick = useCallback(() => {
setEnableRotateOrMirror((m) => {
if (m !== 'mirror') {
diff --git a/packages/convert/app/components/FileAvailable.tsx b/packages/convert/app/components/FileAvailable.tsx
index 77b95ebba7..cffe6fefc9 100644
--- a/packages/convert/app/components/FileAvailable.tsx
+++ b/packages/convert/app/components/FileAvailable.tsx
@@ -1,6 +1,6 @@
import type {ParseMediaOnProgress} from '@remotion/media-parser';
-import {WebCodecsInternals} from '@remotion/webcodecs';
import React, {useCallback, useMemo, useRef, useState} from 'react';
+import {normalizeVideoRotation} from '~/lib/calculate-new-dimensions-from-dimensions';
import type {Source} from '~/lib/convert-state';
import type {RotateOrMirrorState} from '~/lib/default-ui';
import {defaultRotateOrMirorState} from '~/lib/default-ui';
@@ -64,7 +64,7 @@ export const FileAvailable: React.FC<{
return 0;
}
- return WebCodecsInternals.normalizeVideoRotation(userRotation);
+ return normalizeVideoRotation(userRotation);
}, [enableRotateOrMirrow, userRotation]);
return (
diff --git a/packages/convert/app/components/VideoCodecSelection.tsx b/packages/convert/app/components/VideoCodecSelection.tsx
index 5932e3ab07..1d1dd51400 100644
--- a/packages/convert/app/components/VideoCodecSelection.tsx
+++ b/packages/convert/app/components/VideoCodecSelection.tsx
@@ -1,6 +1,6 @@
-import type {VideoOperation} from '@remotion/webcodecs';
import type {InputVideoTrack} from 'mediabunny';
import React from 'react';
+import type {VideoOperation} from '~/lib/audio-operation';
import {getVideoOperationId} from '~/lib/operation-key';
import {
Select,
diff --git a/packages/convert/app/components/VideoOperationOption.tsx b/packages/convert/app/components/VideoOperationOption.tsx
index 8efb8e1748..425bc2e8cb 100644
--- a/packages/convert/app/components/VideoOperationOption.tsx
+++ b/packages/convert/app/components/VideoOperationOption.tsx
@@ -1,5 +1,5 @@
-import type {VideoOperation} from '@remotion/webcodecs';
import type {InputVideoTrack} from 'mediabunny';
+import type {VideoOperation} from '~/lib/audio-operation';
import {renderHumanReadableVideoCodec} from '~/lib/render-codec-label';
export const VideoOperationOption: React.FC<{
diff --git a/packages/convert/app/components/get-supported-configs.tsx b/packages/convert/app/components/get-supported-configs.tsx
index 39aba1f45a..d43ae62820 100644
--- a/packages/convert/app/components/get-supported-configs.tsx
+++ b/packages/convert/app/components/get-supported-configs.tsx
@@ -1,14 +1,4 @@
-import type {
- MediaParserAudioCodec,
- MediaParserContainer,
- MediaParserTrack,
-} from '@remotion/media-parser';
-import type {
- AudioOperation,
- ConvertMediaContainer,
- ResizeOperation,
- VideoOperation,
-} from '@remotion/webcodecs';
+import type {MediaParserContainer} from '@remotion/media-parser';
import {
canCopyAudioTrack,
canCopyVideoTrack,
@@ -17,7 +7,10 @@ import {
getAvailableAudioCodecs,
getAvailableVideoCodecs,
} from '@remotion/webcodecs';
-import type {RouteAction} from '~/seo';
+import type {InputAudioTrack, InputTrack} from 'mediabunny';
+import type {AudioOperation, VideoOperation} from '~/lib/audio-operation';
+import type {MediabunnyResize} from '~/lib/mediabunny-calculate-resize-option';
+import type {OutputContainer, RouteAction} from '~/seo';
export type VideoTrackOption = {
trackId: number;
@@ -27,7 +20,7 @@ export type VideoTrackOption = {
export type AudioTrackOption = {
trackId: number;
operations: AudioOperation[];
- audioCodec: MediaParserAudioCodec;
+ audioCodec: InputAudioTrack['codec'];
};
export type SupportedConfigs = {
@@ -93,13 +86,13 @@ export const getSupportedConfigs = async ({
resizeOperation,
sampleRate,
}: {
- tracks: MediaParserTrack[];
- container: ConvertMediaContainer;
+ tracks: InputTrack[];
+ container: OutputContainer;
bitrate: number;
action: RouteAction;
userRotation: number;
inputContainer: MediaParserContainer;
- resizeOperation: ResizeOperation | null;
+ resizeOperation: MediabunnyResize | null;
sampleRate: number | null;
}): Promise<SupportedConfigs> => {
const availableVideoCodecs = getAvailableVideoCodecs({container});
diff --git a/packages/convert/app/components/use-probe.ts b/packages/convert/app/components/use-probe.ts
index 10d68fa8ed..3656b22180 100644
--- a/packages/convert/app/components/use-probe.ts
+++ b/packages/convert/app/components/use-probe.ts
@@ -1,36 +1,25 @@
import type {
- MediaParserAudioCodec,
- MediaParserContainer,
MediaParserController,
MediaParserDimensions,
- MediaParserEmbeddedImage,
MediaParserKeyframe,
- MediaParserLocation,
- MediaParserLogLevel,
- MediaParserMetadataEntry,
- MediaParserTrack,
- ParseMediaOnProgress,
} from '@remotion/media-parser';
import {mediaParserController} from '@remotion/media-parser';
-import {parseMediaOnWebWorker} from '@remotion/media-parser/worker';
-import type {InputVideoTrack} from 'mediabunny';
+import type {
+ InputAudioTrack,
+ InputFormat,
+ InputTrack,
+ InputVideoTrack,
+ MetadataTags,
+} from 'mediabunny';
import {ALL_FORMATS, BlobSource, Input, UrlSource} from 'mediabunny';
import {useCallback, useEffect, useMemo, useState} from 'react';
import type {Source} from '~/lib/convert-state';
export type ProbeResult = ReturnType<typeof useProbe>;
-export const useProbe = ({
- src,
- logLevel,
- onProgress,
-}: {
- src: Source;
- logLevel: MediaParserLogLevel;
- onProgress: ParseMediaOnProgress;
-}) => {
+export const useProbe = ({src}: {src: Source}) => {
const [audioCodec, setAudioCodec] = useState<
- MediaParserAudioCodec | null | undefined
+ InputAudioTrack['codec'] | null | undefined
>(undefined);
const [fps, setFps] = useState<number | null | undefined>(undefined);
const [isHdr, setHdr] = useState<boolean | undefined>(undefined);
@@ -48,17 +37,13 @@ export const useProbe = ({
>(undefined);
const [rotation, setRotation] = useState<number | null>(null);
const [size, setSize] = useState<number | null>(null);
- const [metadata, setMetadata] = useState<MediaParserMetadataEntry[] | null>(
- null,
- );
- const [location, setLocation] = useState<MediaParserLocation | null>(null);
- const [tracks, setTracks] = useState<MediaParserTrack[] | null>(null);
- const [container, setContainer] = useState<MediaParserContainer | null>(null);
+ const [metadata, setMetadata] = useState<MetadataTags | null>(null);
+ const [tracks, setTracks] = useState<InputTrack[] | null>(null);
+ const [container, setContainer] = useState<InputFormat | null>(null);
const [keyframes, setKeyframes] = useState<MediaParserKeyframe[] | null>(
null,
);
const [sampleRate, setSampleRate] = useState<number | null>(null);
- const [images, setImages] = useState<MediaParserEmbeddedImage[] | null>(null);
const [done, setDone] = useState(false);
const [error, setError] = useState<Error | null>(null);
@@ -67,6 +52,10 @@ export const useProbe = ({
);
const getStart = useCallback(() => {
+ // TODO: Name
+ // TODO: HDR
+ // TODO: Keyframes
+ // TODO: Smart parallelization
const input = new Input({
formats: ALL_FORMATS,
source:
@@ -74,96 +63,55 @@ export const useProbe = ({
});
const run = async () => {
- const duration = await input.computeDuration();
- setDurationInSeconds(duration);
+ const format = await input.getFormat();
+ setContainer(format);
- const videoTrack = await input.getPrimaryVideoTrack();
- if (videoTrack) {
- const {codec} = videoTrack;
- setVideoCodec(codec);
- const packetStats = await videoTrack.computePacketStats(50);
- setFps(packetStats.averagePacketRate);
- }
- };
+ const s = await input.source.getSize();
+ setSize(s);
- run();
-
- parseMediaOnWebWorker({
- logLevel,
- src: src.type === 'file' ? src.file : src.url,
- onParseProgress: onProgress,
- controller,
- onMetadata: (newMetadata) => {
- setMetadata(newMetadata);
- },
- onContainer(c) {
- setContainer(c);
- },
- onAudioCodec: (codec) => {
- setAudioCodec(codec);
- },
- onIsHdr: (hdr) => {
- setHdr(hdr);
- },
- onRotation(newRotation) {
- setRotation(newRotation);
- },
- onName: (n) => {
- setName(n);
- },
- onDimensions(dim) {
- setDimensions(dim);
- },
- onUnrotatedDimensions(dim) {
- setUnrotatedDimensions(dim);
- },
- onTracks: (trx) => {
- setTracks(trx);
- },
- onLocation: (l) => {
- setLocation(l);
- },
- onSize: (s) => {
- setSize(s);
- },
- onKeyframes: (k) => {
- setKeyframes(k);
- },
- onSampleRate(s) {
- setSampleRate(s);
- },
- onImages: (i) => {
- setImages(i);
- },
- acknowledgeRemotionLicense: true,
- })
- .then(() => {})
- .catch((err) => {
- if ((err as Error).stack?.includes('Cancelled')) {
- return;
- }
+ const duration = await input.computeDuration();
+ setDurationInSeconds(duration);
- if ((err as Error).stack?.toLowerCase()?.includes('aborted')) {
- return;
- }
+ const metadataTags = await input.getMetadataTags();
+ setMetadata(metadataTags);
- // firefox
- if ((err as Error).message?.toLowerCase()?.includes('aborted')) {
- return;
+ const trx = await input.getTracks();
+ setTracks(trx);
+ for (const track of trx) {
+ if (track.isVideoTrack()) {
+ const {codec} = track;
+ setVideoCodec(codec);
+ const packetStats = await track.computePacketStats(50);
+ setFps(packetStats.averagePacketRate);
+ setDimensions({
+ width: track.displayWidth,
+ height: track.displayHeight,
+ });
+ setRotation(track.rotation);
+ setUnrotatedDimensions({
+ width: track.codedWidth,
+ height: track.codedHeight,
+ });
+ } else if (track.isAudioTrack()) {
+ const {codec} = track;
+ setAudioCodec(codec);
+ setSampleRate(track.sampleRate);
}
+ }
+ };
- setError(err as Error);
- // eslint-disable-next-line no-console
- console.log(err);
- })
- .finally(() => {
+ run()
+ .then(() => {
setDone(true);
+ })
+ .catch((e) => {
+ setError(e);
});
return () => {
input.dispose();
};
- }, [src, logLevel, onProgress, controller]);
+ }, [src]);
useEffect(() => {
const cleanup = getStart();
@@ -188,10 +136,8 @@ export const useProbe = ({
error,
rotation,
metadata,
- location,
keyframes,
unrotatedDimensions,
- images,
controller,
sampleRate,
};
@@ -210,10 +156,8 @@ export const useProbe = ({
error,
rotation,
metadata,
- location,
keyframes,
unrotatedDimensions,
- images,
controller,
sampleRate,
]);
diff --git a/packages/convert/app/components/use-supported-configs.ts b/packages/convert/app/components/use-supported-configs.ts
index 50357bc351..efd8b7803f 100644
--- a/packages/convert/app/components/use-supported-configs.ts
+++ b/packages/convert/app/components/use-supported-configs.ts
@@ -2,8 +2,8 @@ import type {
MediaParserContainer,
MediaParserTrack,
} from '@remotion/media-parser';
-import type {ResizeOperation} from '@remotion/webcodecs';
import {useEffect, useState} from 'react';
+import type {MediabunnyResize} from '~/lib/mediabunny-calculate-resize-option';
import type {OutputContainer, RouteAction} from '~/seo';
import type {SupportedConfigs} from './get-supported-configs';
import {getSupportedConfigs} from './get-supported-configs';
@@ -21,7 +21,7 @@ export const useSupportedConfigs = ({
tracks: MediaParserTrack[] | null;
action: RouteAction;
userRotation: number;
- resizeOperation: ResizeOperation | null;
+ resizeOperation: MediabunnyResize | null;
inputContainer: MediaParserContainer | null;
sampleRate: number | null;
}) => {
diff --git a/packages/convert/app/lib/audio-operation.ts b/packages/convert/app/lib/audio-operation.ts
new file mode 100644
index 0000000000..3253c0a7e2
--- /dev/null
+++ b/packages/convert/app/lib/audio-operation.ts
@@ -0,0 +1,24 @@
+import type {InputAudioTrack, InputVideoTrack} from 'mediabunny';
+import type {MediabunnyResize} from './mediabunny-calculate-resize-option';
+
+export type AudioOperation =
+ | {
+ type: 'reencode';
+ bitrate: number;
+ audioCodec: InputAudioTrack['codec'];
+ sampleRate: number | null;
+ }
+ | {type: 'copy'}
+ | {type: 'fail'}
+ | {type: 'drop'};
+
+export type VideoOperation =
+ | {
+ type: 'reencode';
+ videoCodec: InputVideoTrack['codec'];
+ rotate?: number;
+ resize?: MediabunnyResize | null;
+ }
+ | {type: 'copy'}
+ | {type: 'drop'}
+ | {type: 'fail'};
diff --git a/packages/convert/app/lib/calculate-new-dimensions-from-dimensions.ts b/packages/convert/app/lib/calculate-new-dimensions-from-dimensions.ts
new file mode 100644
index 0000000000..7bab17f33d
--- /dev/null
+++ b/packages/convert/app/lib/calculate-new-dimensions-from-dimensions.ts
@@ -0,0 +1,130 @@
+import type {MediabunnyResize} from './mediabunny-calculate-resize-option';
+
+type Dimensions = {
+ width: number;
+ height: number;
+};
+
+const ensureMultipleOfTwo = ({
+ dimensions,
+ needsToBeMultipleOfTwo,
+}: {
+ dimensions: Dimensions;
+ needsToBeMultipleOfTwo: boolean;
+}): Dimensions => {
+ if (!needsToBeMultipleOfTwo) {
+ return dimensions;
+ }
+
+ return {
+ width: Math.floor(dimensions.width / 2) * 2,
+ height: Math.floor(dimensions.height / 2) * 2,
+ };
+};
+
+export const calculateNewSizeAfterResizing = ({
+ dimensions,
+ resizeOperation,
+ needsToBeMultipleOfTwo,
+}: {
+ dimensions: Dimensions;
+ resizeOperation: MediabunnyResize | null;
+ needsToBeMultipleOfTwo: boolean;
+}) => {
+ if (resizeOperation === null) {
+ return ensureMultipleOfTwo({
+ dimensions,
+ needsToBeMultipleOfTwo,
+ });
+ }
+
+ if (resizeOperation.mode === 'max-height') {
+ const height = Math.min(dimensions.height, resizeOperation.maxHeight);
+ return ensureMultipleOfTwo({
+ dimensions: {
+ width: Math.round((height / dimensions.height) * dimensions.width),
+ height,
+ },
+ needsToBeMultipleOfTwo,
+ });
+ }
+
+ if (resizeOperation.mode === 'max-width') {
+ const width = Math.min(dimensions.width, resizeOperation.maxWidth);
+ return ensureMultipleOfTwo({
+ dimensions: {
+ width,
+ height: Math.round((width / dimensions.width) * dimensions.height),
+ },
+ needsToBeMultipleOfTwo,
+ });
+ }
+
+ if (resizeOperation.mode === 'scale') {
+ if (resizeOperation.scale <= 0) {
+ throw new Error('Scale must be greater than 0');
+ }
+
+ const width = Math.round(dimensions.width * resizeOperation.scale);
+ const height = Math.round(dimensions.height * resizeOperation.scale);
+ return ensureMultipleOfTwo({
+ dimensions: {
+ width,
+ height,
+ },
+ needsToBeMultipleOfTwo,
+ });
+ }
+
+ throw new Error('Invalid resizing mode ' + (resizeOperation satisfies never));
+};
+
+export const normalizeVideoRotation = (rotation: number) => {
+ return ((rotation % 360) + 360) % 360;
+};
+
+export const calculateNewDimensionsFromRotate = ({
+ height,
+ width,
+ rotation,
+}: Dimensions & {
+ rotation: number;
+}) => {
+ const normalized = normalizeVideoRotation(rotation);
+ const switchDimensions = normalized % 90 === 0 && normalized % 180 !== 0;
+
+ const newHeight = switchDimensions ? width : height;
+ const newWidth = switchDimensions ? height : width;
+ return {
+ height: newHeight,
+ width: newWidth,
+ };
+};
+
+export const calculateNewDimensionsFromRotateAndScale = ({
+ width,
+ height,
+ rotation,
+ resizeOperation,
+ needsToBeMultipleOfTwo,
+}: {
+ width: number;
+ height: number;
+ rotation: number;
+ resizeOperation: MediabunnyResize | null;
+ needsToBeMultipleOfTwo: boolean;
+}) => {
+ const {height: newHeight, width: newWidth} = calculateNewDimensionsFromRotate(
+ {
+ height,
+ rotation,
+ width,
+ },
+ );
+
+ return calculateNewSizeAfterResizing({
+ dimensions: {height: newHeight, width: newWidth},
+ resizeOperation,
+ needsToBeMultipleOfTwo,
+ });
+};
diff --git a/packages/convert/app/lib/get-audio-video-config-index.ts b/packages/convert/app/lib/get-audio-video-config-index.ts
index 7710794ada..b687c00912 100644
--- a/packages/convert/app/lib/get-audio-video-config-index.ts
+++ b/packages/convert/app/lib/get-audio-video-config-index.ts
@@ -1,4 +1,4 @@
-import type {AudioOperation, VideoOperation} from '@remotion/webcodecs';
+import type {AudioOperation, VideoOperation} from './audio-operation';
import {getAudioOperationId, getVideoOperationId} from './operation-key';
export const getActualAudioConfigIndex = ({
diff --git a/packages/convert/app/lib/operation-key.ts b/packages/convert/app/lib/operation-key.ts
index 8ee5a81b62..9e66b55a3f 100644
--- a/packages/convert/app/lib/operation-key.ts
+++ b/packages/convert/app/lib/operation-key.ts
@@ -1,4 +1,4 @@
-import type {AudioOperation, VideoOperation} from '@remotion/webcodecs';
+import type {AudioOperation, VideoOperation} from './audio-operation';
export const getVideoOperationId = (operation: VideoOperation) => {
if (operation.type === 'copy') {
diff --git a/packages/convert/app/lib/render-codec-label.ts b/packages/convert/app/lib/render-codec-label.ts
index 29ecebbc01..782087a9fb 100644
--- a/packages/convert/app/lib/render-codec-label.ts
+++ b/packages/convert/app/lib/render-codec-label.ts
@@ -1,17 +1,8 @@
-import type {
- MediaParserAudioCodec,
- MediaParserContainer,
- MediaParserVideoCodec,
-} from '@remotion/media-parser';
-import type {ConvertMediaAudioCodec} from '@remotion/webcodecs';
import type {InputAudioTrack, InputVideoTrack} from 'mediabunny';
import type {OutputContainer} from '~/seo';
export const renderHumanReadableAudioCodec = (
- codec:
- | InputAudioTrack['codec']
- | MediaParserAudioCodec
- | ConvertMediaAudioCodec,
+ codec: InputAudioTrack['codec'],
) => {
if (codec === 'opus') {
return 'Opus';
@@ -49,10 +40,6 @@ export const renderHumanReadableAudioCodec = (
return 'Vorbis';
}
- if (codec === 'wav') {
- return 'WAV';
- }
-
if (codec === 'flac') {
return 'FLAC';
}
@@ -109,7 +96,7 @@ export const renderHumanReadableAudioCodec = (
};
export const renderHumanReadableVideoCodec = (
- codec: InputVideoTrack['codec'] | MediaParserVideoCodec,
+ codec: InputVideoTrack['codec'],
) => {
if (codec === 'vp8') {
return 'VP8';
@@ -150,9 +137,7 @@ export const renderHumanReadableVideoCodec = (
throw new Error(`Unknown video codec ${codec satisfies never}`);
};
-export const renderHumanReadableContainer = (
- container: MediaParserContainer | OutputContainer,
-) => {
+export const renderHumanReadableContainer = (container: OutputContainer) => {
if (container === 'webm') {
return '.webm';
}
diff --git a/packages/webcodecs/src/index.ts b/packages/webcodecs/src/index.ts
index 236c7e3738..5ebaa63e85 100644
--- a/packages/webcodecs/src/index.ts
+++ b/packages/webcodecs/src/index.ts
@@ -2,7 +2,6 @@ import {
normalizeVideoRotation,
rotateAndResizeVideoFrame,
} from './rotate-and-resize-video-frame';
-import {calculateNewDimensionsFromRotateAndScale} from './rotation';
import {setRemotionImported} from './set-remotion-imported';
export {createAudioEncoder} from './audio-encoder';
@@ -66,8 +65,6 @@ export type {WebCodecsController} from './webcodecs-controller';
export const WebCodecsInternals = {
rotateAndResizeVideoFrame,
normalizeVideoRotation,
- calculateNewDimensionsFromDimensions:
- calculateNewDimensionsFromRotateAndScale,
};
setRemotionImported();