Skip to content

🎥 Make videos programmatically with React

option resolution

Jonny Burgerc95fca8d2dd4
diff --git a/packages/convert/app/components/AudioCodecSelection.tsx b/packages/convert/app/components/AudioCodecSelection.tsx
index 2cb5f43037..fade9d9ff0 100644
--- a/packages/convert/app/components/AudioCodecSelection.tsx
+++ b/packages/convert/app/components/AudioCodecSelection.tsx
@@ -1,3 +1,4 @@
+import {MediaParserAudioCodec} from '@remotion/media-parser';
import {AudioOperation} from '@remotion/webcodecs';
import React from 'react';
import {AudioOperationOption} from './AudioOperationOption';
@@ -14,7 +15,12 @@ export const AudioCodecSelection: React.FC<{
readonly audioTrackOptions: AudioOperation[];
readonly index: number;
readonly setIndex: (v: number) => void;
-}> = ({audioTrackOptions, index, setIndex}) => {
+ readonly currentAudioCodec: MediaParserAudioCodec | null;
+}> = ({audioTrackOptions, index, setIndex, currentAudioCodec}) => {
+ if (!currentAudioCodec) {
+ throw new Error('No current audio codec, should not render this component');
+ }
+
return (
<Select value={String(index)} onValueChange={(v) => setIndex(Number(v))}>
<SelectTrigger id="audioCodec">
@@ -28,7 +34,10 @@ export const AudioCodecSelection: React.FC<{
// eslint-disable-next-line react/jsx-key
value={String(i)}
>
- <AudioOperationOption operation={operation} />
+ <AudioOperationOption
+ currentAudioCodec={currentAudioCodec}
+ operation={operation}
+ />
</SelectItem>
</SelectGroup>
);
diff --git a/packages/convert/app/components/AudioOperationOption.tsx b/packages/convert/app/components/AudioOperationOption.tsx
index a004d146b1..d2b3cbe8b9 100644
--- a/packages/convert/app/components/AudioOperationOption.tsx
+++ b/packages/convert/app/components/AudioOperationOption.tsx
@@ -1,15 +1,17 @@
+import {MediaParserAudioCodec} from '@remotion/media-parser';
import {AudioOperation} from '@remotion/webcodecs';
-import {renderAudioCodecLabel} from '@remotion/webcodecs/src/codec-id';
+import {renderHumanReadableAudioCodec} from '~/lib/render-codec-label';
export const AudioOperationOption: React.FC<{
readonly operation: AudioOperation;
-}> = ({operation}) => {
+ readonly currentAudioCodec: MediaParserAudioCodec;
+}> = ({operation, currentAudioCodec}) => {
if (operation.type === 'reencode') {
- return renderAudioCodecLabel(operation.audioCodec);
+ return renderHumanReadableAudioCodec(operation.audioCodec);
}
if (operation.type === 'copy') {
- return 'Copy without re-encoding';
+ return `Copy ${renderHumanReadableAudioCodec(currentAudioCodec)} without re-encoding`;
}
if (operation.type === 'drop') {
diff --git a/packages/convert/app/components/AudioTrackOverview.tsx b/packages/convert/app/components/AudioTrackOverview.tsx
index d30dc1b345..e2974a8f9f 100644
--- a/packages/convert/app/components/AudioTrackOverview.tsx
+++ b/packages/convert/app/components/AudioTrackOverview.tsx
@@ -1,4 +1,5 @@
import type {AudioTrack} from '@remotion/media-parser';
+import {renderHumanReadableAudioCodec} from '~/lib/render-codec-label';
import {Table, TableBody, TableCell, TableRow} from './ui/table';
export const AudioTrackOverview: React.FC<{
@@ -8,25 +9,35 @@ export const AudioTrackOverview: React.FC<{
<Table>
<TableBody>
<TableRow>
- <TableCell colSpan={3}>Type</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Type
+ </TableCell>
<TableCell className="text-right">Audio</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>Codec</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Codec
+ </TableCell>
<TableCell className="text-right">
- {track.codecWithoutConfig}
+ {renderHumanReadableAudioCodec(track.codecWithoutConfig)}
</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>WebCodecs Codec String</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ WebCodecs Codec String
+ </TableCell>
<TableCell className="text-right">{track.codec}</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>Channels</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Channels
+ </TableCell>
<TableCell className="text-right">{track.numberOfChannels}</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>Sample Rate</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Sample Rate
+ </TableCell>
<TableCell className="text-right">{track.sampleRate}</TableCell>
</TableRow>
</TableBody>
diff --git a/packages/convert/app/components/ContainerOverview.tsx b/packages/convert/app/components/ContainerOverview.tsx
index 5ff728bc0f..330b230506 100644
--- a/packages/convert/app/components/ContainerOverview.tsx
+++ b/packages/convert/app/components/ContainerOverview.tsx
@@ -8,6 +8,10 @@ import type {
import React from 'react';
import {formatBytes} from '~/lib/format-bytes';
import {formatSeconds} from '~/lib/format-seconds';
+import {
+ renderHumanReadableAudioCodec,
+ renderHumanReadableVideoCodec,
+} from '~/lib/render-codec-label';
import {Skeleton} from './ui/skeleton';
export const ContainerOverview: React.FC<{
@@ -102,7 +106,7 @@ export const ContainerOverview: React.FC<{
{videoCodec === null ? (
<Skeleton className="h-3 w-[100px] inline-block" />
) : (
- videoCodec
+ renderHumanReadableVideoCodec(videoCodec)
)}
</TableCell>
</TableRow>
@@ -116,7 +120,7 @@ export const ContainerOverview: React.FC<{
) : audioCodec === null ? (
'No audio'
) : (
- audioCodec
+ renderHumanReadableAudioCodec(audioCodec)
)}
</TableCell>
</TableRow>
diff --git a/packages/convert/app/components/ConvertForm.tsx b/packages/convert/app/components/ConvertForm.tsx
index c21421cbf1..83eb77409e 100644
--- a/packages/convert/app/components/ConvertForm.tsx
+++ b/packages/convert/app/components/ConvertForm.tsx
@@ -1,3 +1,7 @@
+import {
+ MediaParserAudioCodec,
+ MediaParserVideoCodec,
+} from '@remotion/media-parser';
import {ConvertMediaContainer} from '@remotion/webcodecs';
import React from 'react';
import {Container} from '~/lib/generate-new-name';
@@ -31,6 +35,8 @@ export const ConvertForm: React.FC<{
readonly audioConfigIndex: Record<number, number>;
readonly setAudioConfigIndex: (trackId: number, i: number) => void;
readonly setVideoConfigIndex: (trackId: number, i: number) => void;
+ readonly currentAudioCodec: MediaParserAudioCodec | null;
+ readonly currentVideoCodec: MediaParserVideoCodec | null;
}> = ({
container,
setContainer,
@@ -43,6 +49,8 @@ export const ConvertForm: React.FC<{
setAudioConfigIndex,
videoConfigIndex,
setVideoConfigIndex,
+ currentAudioCodec,
+ currentVideoCodec,
}) => {
const [showAdvanced, setShowAdvanced] = React.useState(false);
@@ -78,6 +86,7 @@ export const ConvertForm: React.FC<{
setVideoConfigIndex(track.trackId, i);
}}
videoOperations={track.operations}
+ currentVideoCodec={currentVideoCodec}
/>
</div>
);
@@ -99,6 +108,7 @@ export const ConvertForm: React.FC<{
setAudioConfigIndex(track.trackId, i);
}}
audioTrackOptions={track.operations}
+ currentAudioCodec={currentAudioCodec}
/>
</div>
);
diff --git a/packages/convert/app/components/ConvertUi.tsx b/packages/convert/app/components/ConvertUi.tsx
index 5681129499..0070f2d35c 100644
--- a/packages/convert/app/components/ConvertUi.tsx
+++ b/packages/convert/app/components/ConvertUi.tsx
@@ -1,6 +1,10 @@
import {Button} from '@/components/ui/button';
import {CardTitle} from '@/components/ui/card';
-import {MediaParserInternals} from '@remotion/media-parser';
+import {
+ MediaParserAudioCodec,
+ MediaParserInternals,
+ MediaParserVideoCodec,
+} from '@remotion/media-parser';
import {fetchReader} from '@remotion/media-parser/fetch';
import {webFileReader} from '@remotion/media-parser/web-file';
import {convertMedia, ConvertMediaContainer} from '@remotion/webcodecs';
@@ -17,9 +21,13 @@ import {Badge} from './ui/badge';
export default function ConvertUI({
src,
supportedConfigs,
+ currentAudioCodec,
+ currentVideoCodec,
}: {
readonly src: Source;
readonly supportedConfigs: SupportedConfigs | null;
+ readonly currentAudioCodec: MediaParserAudioCodec | null;
+ readonly currentVideoCodec: MediaParserVideoCodec | null;
}) {
const [container, setContainer] = useState<ConvertMediaContainer>('webm');
const [videoConfigIndex, _setVideoConfigIndex] = useState<
@@ -282,6 +290,8 @@ export default function ConvertUI({
videoConfigIndex,
setAudioConfigIndex,
setVideoConfigIndex,
+ currentAudioCodec,
+ currentVideoCodec,
}}
/>
</div>
diff --git a/packages/convert/app/components/FileAvailable.tsx b/packages/convert/app/components/FileAvailable.tsx
index 7bd7da1b83..d2136b331f 100644
--- a/packages/convert/app/components/FileAvailable.tsx
+++ b/packages/convert/app/components/FileAvailable.tsx
@@ -1,3 +1,7 @@
+import {
+ MediaParserAudioCodec,
+ MediaParserVideoCodec,
+} from '@remotion/media-parser';
import React, {useCallback, useState} from 'react';
import {Source} from '~/lib/convert-state';
import ConvertUI from './ConvertUi';
@@ -12,6 +16,10 @@ export const FileAvailable: React.FC<{
const [probeDetails, setProbeDetails] = useState(false);
const [supportedConfigs, setSupportedConfigs] =
useState<SupportedConfigs | null>(null);
+ const [currentAudioCodec, setCurrentAudioCodec] =
+ useState<MediaParserAudioCodec | null>(null);
+ const [currentVideoCodec, setCurrentVideoCodec] =
+ useState<MediaParserVideoCodec | null>(null);
const clear = useCallback(() => {
setSrc(null);
@@ -48,10 +56,17 @@ export const FileAvailable: React.FC<{
src={src}
probeDetails={probeDetails}
setProbeDetails={setProbeDetails}
+ setAudioCodec={setCurrentAudioCodec}
+ setVideoCodec={setCurrentVideoCodec}
onSupportedConfigs={onSupportedConfigs}
/>
<div className="h-8 lg:h-0 lg:w-8" />
- <ConvertUI supportedConfigs={supportedConfigs} src={src} />
+ <ConvertUI
+ currentAudioCodec={currentAudioCodec}
+ currentVideoCodec={currentVideoCodec}
+ supportedConfigs={supportedConfigs}
+ src={src}
+ />
</div>
</div>
</div>
diff --git a/packages/convert/app/components/Probe.tsx b/packages/convert/app/components/Probe.tsx
index 1375c3f8e1..eee63c3797 100644
--- a/packages/convert/app/components/Probe.tsx
+++ b/packages/convert/app/components/Probe.tsx
@@ -1,3 +1,7 @@
+import {
+ MediaParserAudioCodec,
+ MediaParserVideoCodec,
+} from '@remotion/media-parser';
import React, {useCallback, useMemo, useRef, useState} from 'react';
import {Source} from '~/lib/convert-state';
import {useIsNarrow} from '~/lib/is-narrow';
@@ -18,9 +22,22 @@ import {useProbe} from './use-probe';
export const Probe: React.FC<{
readonly src: Source;
readonly setProbeDetails: React.Dispatch<React.SetStateAction<boolean>>;
+ readonly setAudioCodec: React.Dispatch<
+ React.SetStateAction<MediaParserAudioCodec | null>
+ >;
+ readonly setVideoCodec: React.Dispatch<
+ React.SetStateAction<MediaParserVideoCodec | null>
+ >;
readonly probeDetails: boolean;
readonly onSupportedConfigs: (supportedConfigs: SupportedConfigs) => void;
-}> = ({src, probeDetails, setProbeDetails, onSupportedConfigs}) => {
+}> = ({
+ src,
+ probeDetails,
+ setProbeDetails,
+ onSupportedConfigs,
+ setAudioCodec,
+ setVideoCodec,
+}) => {
const videoThumbnailRef = useRef<VideoThumbnailRef>(null);
const onVideoThumbnail = useCallback((frame: VideoFrame) => {
@@ -37,7 +54,13 @@ export const Probe: React.FC<{
size,
videoCodec,
durationInSeconds,
- } = useProbe({src, onVideoThumbnail, onSupportedConfigs});
+ } = useProbe({
+ src,
+ onVideoThumbnail,
+ onSupportedConfigs,
+ onAudioCodec: setAudioCodec,
+ onVideoCodec: setVideoCodec,
+ });
const onClick = useCallback(() => {
setProbeDetails((p) => !p);
diff --git a/packages/convert/app/components/VideoCodecSelection.tsx b/packages/convert/app/components/VideoCodecSelection.tsx
index 77c5911094..dbf0b315d1 100644
--- a/packages/convert/app/components/VideoCodecSelection.tsx
+++ b/packages/convert/app/components/VideoCodecSelection.tsx
@@ -1,3 +1,4 @@
+import {MediaParserVideoCodec} from '@remotion/media-parser';
import {VideoOperation} from '@remotion/webcodecs';
import React from 'react';
import {
@@ -14,7 +15,8 @@ export const VideoCodecSelection: React.FC<{
readonly videoOperations: VideoOperation[];
readonly index: number;
readonly setIndex: (v: number) => void;
-}> = ({videoOperations, index, setIndex}) => {
+ readonly currentVideoCodec: MediaParserVideoCodec | null;
+}> = ({videoOperations, index, setIndex, currentVideoCodec}) => {
return (
<Select value={String(index)} onValueChange={(v) => setIndex(Number(v))}>
<SelectTrigger id="videoCodec">
@@ -28,7 +30,10 @@ export const VideoCodecSelection: React.FC<{
// eslint-disable-next-line react/jsx-key
value={String(i)}
>
- <VideoOperationOption operation={operation} />
+ <VideoOperationOption
+ currentVideoCodec={currentVideoCodec}
+ operation={operation}
+ />
</SelectItem>
</SelectGroup>
);
diff --git a/packages/convert/app/components/VideoOperationOption.tsx b/packages/convert/app/components/VideoOperationOption.tsx
index b6d8715a71..0d117d7b47 100644
--- a/packages/convert/app/components/VideoOperationOption.tsx
+++ b/packages/convert/app/components/VideoOperationOption.tsx
@@ -1,15 +1,20 @@
+import {MediaParserVideoCodec} from '@remotion/media-parser';
import {VideoOperation} from '@remotion/webcodecs';
-import {renderVideoCodecLabel} from '@remotion/webcodecs/src/codec-id';
+import {renderHumanReadableVideoCodec} from '~/lib/render-codec-label';
export const VideoOperationOption: React.FC<{
readonly operation: VideoOperation;
-}> = ({operation}) => {
+ currentVideoCodec: MediaParserVideoCodec | null;
+}> = ({operation, currentVideoCodec}) => {
if (operation.type === 'reencode') {
- return renderVideoCodecLabel(operation.videoCodec);
+ return renderHumanReadableVideoCodec(operation.videoCodec);
}
if (operation.type === 'copy') {
- return 'Copy without re-encoding';
+ if (!currentVideoCodec) {
+ throw new Error('No current video codec');
+ }
+ return `Copy ${renderHumanReadableVideoCodec(currentVideoCodec)} without re-encoding`;
}
if (operation.type === 'drop') {
diff --git a/packages/convert/app/components/VideoTrackOverview.tsx b/packages/convert/app/components/VideoTrackOverview.tsx
index 69bc7646bc..b097698f4a 100644
--- a/packages/convert/app/components/VideoTrackOverview.tsx
+++ b/packages/convert/app/components/VideoTrackOverview.tsx
@@ -1,6 +1,7 @@
import {Table, TableBody, TableCell, TableRow} from '@/components/ui/table';
import type {VideoTrack} from '@remotion/media-parser';
import React from 'react';
+import {renderHumanReadableVideoCodec} from '~/lib/render-codec-label';
export const VideoTrackOverview: React.FC<{
readonly track: VideoTrack;
@@ -9,66 +10,90 @@ export const VideoTrackOverview: React.FC<{
<Table>
<TableBody>
<TableRow>
- <TableCell colSpan={3}>Type</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Type
+ </TableCell>
<TableCell className="text-right">Video</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>Codec</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Codec
+ </TableCell>
<TableCell className="text-right">
- {track.codecWithoutConfig}
+ {renderHumanReadableVideoCodec(track.codecWithoutConfig)}
</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>WebCodecs Codec String</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ WebCodecs Codec String
+ </TableCell>
<TableCell className="text-right">{track.codec}</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>Dimensions</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Dimensions
+ </TableCell>
<TableCell className="text-right">
{track.width}x{track.height}
</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>Timescale</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Timescale
+ </TableCell>
<TableCell className="text-right">{track.timescale}</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>Sample Aspect Ratio</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Sample Aspect Ratio
+ </TableCell>
<TableCell className="text-right">
{track.sampleAspectRatio.numerator}:
{track.sampleAspectRatio.denominator}
</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>Rotation</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Rotation
+ </TableCell>
<TableCell className="text-right">{track.rotation}°</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>Unrotated dimensions</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Unrotated dimensions
+ </TableCell>
<TableCell className="text-right">
{track.codedWidth}x{track.codedHeight}
</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>Color Primaries</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Color Primaries
+ </TableCell>
<TableCell className="text-right">
{track.color.primaries ?? 'N/A'}
</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>Color Matrix</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Color Matrix
+ </TableCell>
<TableCell className="text-right">
{track.color.matrixCoefficients ?? 'N/A'}
</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>Color Transfer Characteristics</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Color Transfer Characteristics
+ </TableCell>
<TableCell className="text-right">
{track.color.transferCharacteristics ?? 'N/A'}
</TableCell>
</TableRow>
<TableRow>
- <TableCell colSpan={3}>Color Full Range</TableCell>
+ <TableCell className="font-brand" colSpan={3}>
+ Color Full Range
+ </TableCell>
<TableCell className="text-right">
{track.color.fullRange
? 'Yes'
diff --git a/packages/convert/app/components/get-supported-configs.tsx b/packages/convert/app/components/get-supported-configs.tsx
index e4d2f2647c..e9bdcad6d9 100644
--- a/packages/convert/app/components/get-supported-configs.tsx
+++ b/packages/convert/app/components/get-supported-configs.tsx
@@ -75,6 +75,16 @@ export const getSupportedConfigs = async (
const audioTrackOperations: AudioOperation[] = [];
for (const audioCodec of availableAudioCodecs) {
+ const canCopy = canCopyAudioTrack({
+ inputCodec: track.codecWithoutConfig,
+ outputCodec: audioCodec,
+ container,
+ });
+
+ if (canCopy) {
+ audioTrackOperations.push({type: 'copy'});
+ }
+
const canReencode = await canReencodeAudioTrack({
audioCodec,
track,
@@ -88,16 +98,6 @@ export const getSupportedConfigs = async (
bitrate,
});
}
-
- const canCopy = canCopyAudioTrack({
- inputCodec: track.codecWithoutConfig,
- outputCodec: audioCodec,
- container,
- });
-
- if (canCopy) {
- audioTrackOperations.push({type: 'copy'});
- }
}
audioTrackOperations.push({
type: 'drop',
diff --git a/packages/convert/app/components/use-probe.ts b/packages/convert/app/components/use-probe.ts
index b862200f16..15219e4ced 100644
--- a/packages/convert/app/components/use-probe.ts
+++ b/packages/convert/app/components/use-probe.ts
@@ -16,10 +16,14 @@ export const useProbe = ({
src,
onVideoThumbnail,
onSupportedConfigs,
+ onAudioCodec,
+ onVideoCodec,
}: {
src: Source;
onVideoThumbnail: (videoFrame: VideoFrame) => void;
onSupportedConfigs: (supportedConfigs: SupportedConfigs) => void;
+ onAudioCodec: (codec: MediaParserAudioCodec | null) => void;
+ onVideoCodec: (codec: MediaParserVideoCodec | null) => void;
}) => {
const [audioCodec, setAudioCodec] = useState<
MediaParserAudioCodec | null | undefined
@@ -134,6 +138,7 @@ export const useProbe = ({
},
onAudioCodec: (codec) => {
hasAudioCodec = true;
+ onAudioCodec(codec);
setAudioCodec(codec);
cancelIfDone();
},
@@ -159,6 +164,7 @@ export const useProbe = ({
},
onVideoCodec: (codec) => {
hasVideoCodec = true;
+ onVideoCodec(codec);
setVideoCodec(codec);
cancelIfDone();
},
diff --git a/packages/convert/app/lib/render-codec-label.ts b/packages/convert/app/lib/render-codec-label.ts
new file mode 100644
index 0000000000..d00502fb0d
--- /dev/null
+++ b/packages/convert/app/lib/render-codec-label.ts
@@ -0,0 +1,76 @@
+import {
+ MediaParserAudioCodec,
+ MediaParserVideoCodec,
+} from '@remotion/media-parser';
+
+export const renderHumanReadableAudioCodec = (codec: MediaParserAudioCodec) => {
+ if (codec === 'opus') {
+ return 'Opus';
+ }
+
+ if (codec === 'aac') {
+ return 'AAC';
+ }
+
+ if (codec === 'aiff') {
+ return 'AIFF';
+ }
+
+ if (codec === 'mp3') {
+ return 'MP3';
+ }
+
+ if (codec === 'pcm-f32') {
+ return 'PCM 32-bit float';
+ }
+
+ if (codec === 'pcm-s16') {
+ return 'PCM 16-bit signed integer';
+ }
+
+ if (codec === 'pcm-s24') {
+ return 'PCM 24-bit signed integer';
+ }
+
+ if (codec === 'pcm-s32') {
+ return 'PCM 32-bit signed integer';
+ }
+
+ if (codec === 'pcm-u8') {
+ return 'PCM 8-bit unsigned integer';
+ }
+
+ if (codec === 'vorbis') {
+ return 'Vorbis';
+ }
+
+ throw new Error(`Unknown audio codec ${codec satisfies never}`);
+};
+
+export const renderHumanReadableVideoCodec = (codec: MediaParserVideoCodec) => {
+ if (codec === 'vp8') {
+ return 'VP8';
+ }
+
+ if (codec === 'vp9') {
+ return 'VP9';
+ }
+
+ if (codec === 'av1') {
+ return 'AV1';
+ }
+
+ if (codec === 'h264') {
+ return 'H.264';
+ }
+
+ if (codec === 'h265') {
+ return 'H.265';
+ }
+
+ if (codec === 'prores') {
+ return 'ProRes';
+ }
+
+ throw new Error(`Unknown video codec ${codec satisfies never}`);
+};
diff --git a/packages/webcodecs/src/codec-id.ts b/packages/webcodecs/src/codec-id.ts
index c1eab74ff0..7a51861667 100644
--- a/packages/webcodecs/src/codec-id.ts
+++ b/packages/webcodecs/src/codec-id.ts
@@ -2,26 +2,6 @@ const availableVideoCodecs = ['vp8', 'vp9'] as const;
export const getAvailableVideoCodecs = () => availableVideoCodecs;
export type ConvertMediaVideoCodec = (typeof availableVideoCodecs)[number];
-export const renderVideoCodecLabel = (codec: ConvertMediaVideoCodec) => {
- if (codec === 'vp8') {
- return 'VP8';
- }
-
- if (codec === 'vp9') {
- return 'VP9';
- }
-
- throw new Error(`Unknown video codec ${codec satisfies never}`);
-};
-
const availableAudioCodecs = ['opus'] as const;
export const getAvailableAudioCodecs = () => availableAudioCodecs;
export type ConvertMediaAudioCodec = (typeof availableAudioCodecs)[number];
-
-export const renderAudioCodecLabel = (codec: ConvertMediaAudioCodec) => {
- if (codec === 'opus') {
- return 'Opus';
- }
-
- throw new Error(`Unknown audio codec ${codec satisfies never}`);
-};