Skip to content

Commit

Permalink
audio codec drop warning
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyBurger committed Nov 10, 2024
1 parent c95fca8 commit 975668c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
10 changes: 10 additions & 0 deletions packages/convert/app/components/AudioCodecDropWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

export const AudioCodecDropWarning: React.FC = () => {
return (
<div className="text-sm mt-2 text-muted-foreground">
Your browser doesn't support encoding audio and the audio track cannot be
copied into the new container.
</div>
);
};
54 changes: 32 additions & 22 deletions packages/convert/app/components/AudioCodecSelection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {MediaParserAudioCodec} from '@remotion/media-parser';
import {AudioOperation} from '@remotion/webcodecs';
import React from 'react';
import {AudioCodecDropWarning} from './AudioCodecDropWarning';
import {AudioOperationOption} from './AudioOperationOption';
import {
Select,
Expand All @@ -21,28 +22,37 @@ export const AudioCodecSelection: React.FC<{
throw new Error('No current audio codec, should not render this component');
}

const disabled = audioTrackOptions.length < 2;

return (
<Select value={String(index)} onValueChange={(v) => setIndex(Number(v))}>
<SelectTrigger id="audioCodec">
<SelectValue placeholder="Select a audio codec" />
</SelectTrigger>
<SelectContent>
{audioTrackOptions.map((operation, i) => {
return (
<SelectGroup key={i}>
<SelectItem
// eslint-disable-next-line react/jsx-key
value={String(i)}
>
<AudioOperationOption
currentAudioCodec={currentAudioCodec}
operation={operation}
/>
</SelectItem>
</SelectGroup>
);
})}
</SelectContent>
</Select>
<>
<Select
disabled={disabled}
value={String(index)}
onValueChange={(v) => setIndex(Number(v))}
>
<SelectTrigger id="audioCodec">
<SelectValue placeholder="Select a audio codec" />
</SelectTrigger>
<SelectContent>
{audioTrackOptions.map((operation, i) => {
return (
<SelectGroup key={i}>
<SelectItem
// eslint-disable-next-line react/jsx-key
value={String(i)}
>
<AudioOperationOption
currentAudioCodec={currentAudioCodec}
operation={operation}
/>
</SelectItem>
</SelectGroup>
);
})}
</SelectContent>
</Select>
{disabled ? <AudioCodecDropWarning /> : null}
</>
);
};
6 changes: 5 additions & 1 deletion packages/convert/app/components/VideoCodecSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export const VideoCodecSelection: React.FC<{
readonly currentVideoCodec: MediaParserVideoCodec | null;
}> = ({videoOperations, index, setIndex, currentVideoCodec}) => {
return (
<Select value={String(index)} onValueChange={(v) => setIndex(Number(v))}>
<Select
disabled={videoOperations.length < 2}
value={String(index)}
onValueChange={(v) => setIndex(Number(v))}
>
<SelectTrigger id="videoCodec">
<SelectValue placeholder="Select a video codec" />
</SelectTrigger>
Expand Down

0 comments on commit 975668c

Please sign in to comment.