Skip to content

Commit

Permalink
Use only supported and kown encoders
Browse files Browse the repository at this point in the history
  • Loading branch information
ioppermann committed Sep 26, 2024
1 parent 1fd4ed1 commit 78dc5dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
31 changes: 9 additions & 22 deletions src/misc/controls/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@ import Grid from '@mui/material/Grid';
import MenuItem from '@mui/material/MenuItem';
import Typography from '@mui/material/Typography';

import * as Encoders from '../coders/Encoders';
import Checkbox from '../Checkbox';
import Select from '../Select';

const encoderOptions = {
'libx264': 'H.264 (libx264)',
'h264_nvenc': 'H.264 (NVENC)',
'h264_omx': 'H.264 (OpenMAX IL)',
'h264_v4l2m2m': 'H.264 (V4L2 Memory to Memory)',
'h264_vaapi': 'H.264 (Intel VAAPI)',
'h264_videotoolbox': 'H.264 (VideoToolbox)',
};

function init(settings) {
const initSettings = {
enable: true,
Expand All @@ -28,7 +20,7 @@ function init(settings) {
return initSettings;
}

export default function Control({ settings = {}, encoders = [], onChange = function (settings, automatic) {} }) {
export default function Control({ settings = {}, availableEncoders = [], onChange = function (settings, automatic) {} }) {
settings = init(settings);

// Set the defaults
Expand All @@ -49,24 +41,19 @@ export default function Control({ settings = {}, encoders = [], onChange = funct
onChange(settings, false);
};

const encoders = Encoders.Video.GetCodersForCodec('h264', availableEncoders, 'any');

return (
<Grid container spacing={2}>
<Grid item xs={12}>
<Checkbox label={<Trans>Enable browser-compatible H.264 stream</Trans>} checked={settings.enable} onChange={handleChange('enable')} />
</Grid>
<Grid item xs={12} md={6}>
<Select
label={<Trans>Video Codec</Trans>}
value={settings.video_encoder}
disabled={!settings.enable}
onChange={handleChange('video_encoder')}
>
{Object.entries(encoderOptions).map(([value, label]) => (
encoders.includes(value) && (
<MenuItem key={value} value={value}>
{label}
</MenuItem>
)
<Select label={<Trans>Video Codec</Trans>} value={settings.video_encoder} disabled={!settings.enable} onChange={handleChange('video_encoder')}>
{encoders.map((encoder) => (
<MenuItem key={encoder.coder} value={encoder.coder}>
{encoder.name}
</MenuItem>
))}
</Select>
<Typography variant="caption">
Expand Down
2 changes: 1 addition & 1 deletion src/views/Edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ export default function Edit({ restreamer = null }) {
</Grid>
<Grid item xs={12}>
<PreviewControl
encoders={$skills.encoders.video}
availableEncoders={$skills.encoders.video}
settings={$data.control.preview}
onChange={handleControlChange('preview')}
/>
Expand Down

0 comments on commit 78dc5dd

Please sign in to comment.