Skip to content

Commit

Permalink
Add GPU selector for nvenc encoders
Browse files Browse the repository at this point in the history
  • Loading branch information
ioppermann committed Nov 26, 2024
1 parent c9d1c20 commit 75633bf
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/misc/TextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export default function Component({
rows = 1,
env = false,
type = 'text',
min = null,
max = null,
helperText = null,
onChange = function (value) {},
}) {
Expand All @@ -32,10 +34,30 @@ export default function Component({
);
}

let inputProps = {};

if (min !== null) {
inputProps.min = min;
}

if (max !== null) {
inputProps.max = max;
}

return (
<FormControl variant="outlined" disabled={disabled} fullWidth>
<InputLabel htmlFor={id}>{label}</InputLabel>
<OutlinedInput id={id} value={value} onChange={onChange} endAdornment={adornment} label={label} multiline={multiline} rows={rows} type={type} />
<OutlinedInput
id={id}
value={value}
onChange={onChange}
endAdornment={adornment}
label={label}
multiline={multiline}
rows={rows}
type={type}
inputProps={inputProps}
/>
{helperText && <FormHelperText>{helperText}</FormHelperText>}
</FormControl>
);
Expand Down
6 changes: 6 additions & 0 deletions src/misc/coders/Encoders/video/av1_nvenc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Helper from '../../helper';

function init(initialState) {
const state = {
gpu: '0',
bitrate: '4096',
fps: '25',
gop: '2',
Expand All @@ -31,6 +32,8 @@ function createMapping(settings, stream, skills) {
const local = [
'-codec:v',
'av1_nvenc',
'-gpu',
`${settings.gpu}`,
'-preset:v',
`${settings.preset}`,
'-tune:v',
Expand Down Expand Up @@ -196,6 +199,9 @@ function Coder({ stream = {}, settings = {}, skills = {}, onChange = function (s
<Grid item xs={6}>
<RateControl value={settings.rc} onChange={update('rc')} />
</Grid>
<Grid item xs={6}>
<Video.GPU value={settings.gpu} onChange={update('gpu')} />
</Grid>
</Grid>
);
}
Expand Down
6 changes: 6 additions & 0 deletions src/misc/coders/Encoders/video/h264_nvenc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Helper from '../../helper';

function init(initialState) {
const state = {
gpu: '0',
bitrate: '4096',
fps: '25',
gop: '2',
Expand All @@ -32,6 +33,8 @@ function createMapping(settings, stream, skills) {
const local = [
'-codec:v',
'h264_nvenc',
'-gpu',
`${settings.gpu}`,
'-preset:v',
`${settings.preset}`,
'-tune:v',
Expand Down Expand Up @@ -206,6 +209,9 @@ function Coder({ stream = {}, settings = {}, skills = {}, onChange = function (s
<Grid item xs={6}>
<RateControl value={settings.rc} onChange={update('rc')} />
</Grid>
<Grid item xs={6}>
<Video.GPU value={settings.gpu} onChange={update('gpu')} />
</Grid>
</Grid>
);
}
Expand Down
6 changes: 6 additions & 0 deletions src/misc/coders/Encoders/video/hevc_nvenc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Helper from '../../helper';

function init(initialState) {
const state = {
gpu: '0',
bitrate: '4096',
fps: '25',
gop: '2',
Expand All @@ -32,6 +33,8 @@ function createMapping(settings, stream, skills) {
const local = [
'-codec:v',
'hevc_nvenc',
'-gpu',
`${settings.gpu}`,
'-preset:v',
`${settings.preset}`,
'-tune:v',
Expand Down Expand Up @@ -203,6 +206,9 @@ function Coder({ stream = {}, settings = {}, skills = {}, onChange = function (s
<Grid item xs={6}>
<RateControl value={settings.rc} onChange={update('rc')} />
</Grid>
<Grid item xs={6}>
<Video.GPU value={settings.gpu} onChange={update('gpu')} />
</Grid>
</Grid>
);
}
Expand Down
6 changes: 6 additions & 0 deletions src/misc/coders/settings/Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import MenuItem from '@mui/material/MenuItem';

import Select from '../../../misc/Select';
import SelectCustom from '../../../misc/SelectCustom';
import TextField from '../../../misc/TextField';

function Bitrate({
value = '',
Expand Down Expand Up @@ -322,6 +323,10 @@ function FpsMode({ value = '', onChange = function (event) {} }) {
);
}

function GPU({ value = '', onChange = function (event) {} }) {
return <TextField label={<Trans>GPU</Trans>} value={value} onChange={onChange} type="number" min={0}></TextField>;
}

export default {
Bitrate,
GOP,
Expand All @@ -333,4 +338,5 @@ export default {
Format,
PixFormat,
FpsMode,
GPU,
};

0 comments on commit 75633bf

Please sign in to comment.