-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add h264 player stream for unsupported codecs (experimental)
- Loading branch information
Showing
6 changed files
with
353 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React from 'react'; | ||
|
||
import { Trans } from '@lingui/macro'; | ||
import Grid from '@mui/material/Grid'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
import Typography from '@mui/material/Typography'; | ||
|
||
import Checkbox from '../Checkbox'; | ||
import Select from '../Select'; | ||
|
||
function init(settings) { | ||
const initSettings = { | ||
enable: true, | ||
video_encoder: 'libx264', | ||
audio_encoder: 'aac', | ||
...settings, | ||
}; | ||
|
||
return initSettings; | ||
} | ||
|
||
export default function Control(props) { | ||
const settings = init(props.settings); | ||
const encoders = props.encoders; | ||
|
||
// Set the defaults | ||
React.useEffect(() => { | ||
props.onChange(settings, true); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
const handleChange = (what) => (event) => { | ||
const value = event.target.value; | ||
|
||
if (['enable'].includes(what)) { | ||
settings[what] = !settings[what]; | ||
} else { | ||
settings[what] = value; | ||
} | ||
|
||
props.onChange(settings, false); | ||
}; | ||
|
||
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_codec} onChange={handleChange('video_encoder')}> | ||
<MenuItem value="libx264" disabled={!encoders.includes('libx264')}> | ||
H.264 (libx264) | ||
</MenuItem> | ||
<MenuItem value="h264_nvenc" disabled={!encoders.includes('h264_nvenc')}> | ||
<Trans>H.264 (NVENC)</Trans> | ||
</MenuItem> | ||
<MenuItem value="h264_omx" disabled={!encoders.includes('h264_omx')}> | ||
<Trans>H.264 (OpenMAX IL)</Trans> | ||
</MenuItem> | ||
<MenuItem value="h264_v4l2m2m" disabled={!encoders.includes('h264_v4l2m2m')}> | ||
<Trans>H.264 (V4L2 Memory to Memory)</Trans> | ||
</MenuItem> | ||
<MenuItem value="h264_vaapi" disabled={!encoders.includes('h264_vaapi')}> | ||
<Trans>H.264 (Intel VAAPI)</Trans> | ||
</MenuItem> | ||
<MenuItem value="h264_videotoolbox" disabled={!encoders.includes('h264_videotoolbox')}> | ||
<Trans>H.264 (VideoToolbox)</Trans> | ||
</MenuItem> | ||
</Select> | ||
<Typography variant="caption"> | ||
<Trans>The H.264 encoder used.</Trans> | ||
</Typography> | ||
</Grid> | ||
</Grid> | ||
); | ||
} | ||
|
||
Control.defaulProps = { | ||
settings: {}, | ||
onChange: function (settings, automatic) {}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.