Skip to content

🎥 Make videos programmatically with React

new type

Jonny Burger22b744eeee16
diff --git a/packages/docs/docs/webcodecs/convert-media.mdx b/packages/docs/docs/webcodecs/convert-media.mdx
index 1749cb7afb..332f8a6546 100644
--- a/packages/docs/docs/webcodecs/convert-media.mdx
+++ b/packages/docs/docs/webcodecs/convert-media.mdx
@@ -177,14 +177,14 @@ By default the writer is `webFsWriter`.
_Function_ <TsType type="ResolveAudioActionFn" source="@remotion/webcodecs"/>
Take control of what to do for each audio track in the file: Re-encoding, copying, or dropping.
-Documentation for this feature is TODO.
+The API for this feature is not yet documented as it is subject to change.
### `onVideoTrack?`
_Function_ <TsType type="ResolveVideoActionFn" source="@remotion/webcodecs"/>
Take control of what to do for each video track in the file: Re-encoding, copying, or dropping.
-Documentation for this feature is TODO.
+The API for this feature is not yet documented as it is subject to change.
### `fields?` and Callbacks
diff --git a/packages/webcodecs/src/on-audio-track.ts b/packages/webcodecs/src/on-audio-track.ts
index 1e469fdf54..cb035975c5 100644
--- a/packages/webcodecs/src/on-audio-track.ts
+++ b/packages/webcodecs/src/on-audio-track.ts
@@ -55,11 +55,11 @@ export const makeAudioTrackHandler =
logLevel,
});
- if (audioOperation === 'drop') {
+ if (audioOperation.type === 'drop') {
return null;
}
- if (audioOperation === 'copy') {
+ if (audioOperation.type === 'copy') {
const addedTrack = await state.addTrack({
type: 'audio',
codec: audioCodec,
diff --git a/packages/webcodecs/src/resolve-audio-action.ts b/packages/webcodecs/src/resolve-audio-action.ts
index 57191dadcc..607d5746b3 100644
--- a/packages/webcodecs/src/resolve-audio-action.ts
+++ b/packages/webcodecs/src/resolve-audio-action.ts
@@ -6,7 +6,10 @@ import type {
import type {ConvertMediaAudioCodec} from './codec-id';
import {Log} from './log';
-export type AudioOperation = 'reencode' | 'copy' | 'drop';
+export type AudioOperation =
+ | {type: 'reencode'}
+ | {type: 'copy'}
+ | {type: 'drop'};
const canCopyAudioTrack = (
inputCodec: MediaParserAudioCodec,
@@ -29,15 +32,15 @@ export const defaultResolveAudioAction: ResolveAudioActionFn = ({
canCopy,
}) => {
if (canCopy) {
- return 'copy';
+ return {type: 'copy'};
}
if (canReencode) {
- return 'reencode';
+ return {type: 'reencode'};
}
// TODO: Make a fail option?
- return 'drop';
+ return {type: 'drop'};
};
export const resolveAudioAction = async ({