Add GPU selector for decoding and optional resizing for cuvid

This commit is contained in:
Ingo Oppermann 2024-11-26 14:51:02 +01:00
parent 75633bf964
commit 9aff56f76e
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E
11 changed files with 384 additions and 20 deletions

View File

@ -4,6 +4,8 @@ import Helper from '../../helper';
function init(initialState) {
const state = {
gpu: '0',
resize: 'auto',
...initialState,
};

View File

@ -1,9 +1,15 @@
import React from 'react';
import Grid from '@mui/material/Grid';
import { Trans } from '@lingui/macro';
import Helper from '../../helper';
import Video from '../../settings/Video';
function init(initialState) {
const state = {
gpu: '0',
resize: 'auto',
...initialState,
};
@ -14,9 +20,15 @@ function createMapping(settings, stream, skills) {
stream = Helper.InitStream(stream);
skills = Helper.InitSkills(skills);
let local = ['-c:v', 'h264_cuvid', '-gpu', `${settings.gpu}`];
if (settings.resize !== 'auto') {
local.push('-resize', `${settings.resize}`);
}
const mapping = {
global: [],
local: ['-c:v', 'h264_cuvid'],
local: local,
filter: [],
};
@ -38,12 +50,38 @@ function Coder({ stream = {}, settings = {}, skills = {}, onChange = function (s
onChange(newSettings, createMapping(newSettings, stream, skills), automatic);
};
const update = (what) => (event) => {
const newSettings = {
...settings,
[what]: event.target.value,
};
handleChange(newSettings);
};
React.useEffect(() => {
handleChange(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
return (
<Grid container spacing={2}>
<Grid item xs={6}>
<Video.Size
value={settings.resize}
label={<Trans>Resize</Trans>}
customLabel={<Trans>Custom size</Trans>}
onChange={update('resize')}
allowCustom={true}
allowAuto={true}
/>
</Grid>
<Grid item xs={6}>
<Video.GPU value={settings.gpu} onChange={update('gpu')} />
</Grid>
<Grid item xs={12}></Grid>
</Grid>
);
}
// -c:v h264_cuvid -i ...

View File

@ -1,9 +1,15 @@
import React from 'react';
import Grid from '@mui/material/Grid';
import { Trans } from '@lingui/macro';
import Helper from '../../helper';
import Video from '../../settings/Video';
function init(initialState) {
const state = {
gpu: '0',
resize: 'auto',
...initialState,
};
@ -14,9 +20,15 @@ function createMapping(settings, stream, skills) {
stream = Helper.InitStream(stream);
skills = Helper.InitSkills(skills);
let local = ['-c:v', 'hevc_cuvid', '-gpu', `${settings.gpu}`];
if (settings.resize !== 'auto') {
local.push('-resize', `${settings.resize}`);
}
const mapping = {
global: [],
local: ['-c:v', 'hevc_cuvid'],
local: local,
filter: [],
};
@ -38,12 +50,38 @@ function Coder({ stream = {}, settings = {}, skills = {}, onChange = function (s
onChange(newSettings, createMapping(newSettings, stream, skills), automatic);
};
const update = (what) => (event) => {
const newSettings = {
...settings,
[what]: event.target.value,
};
handleChange(newSettings);
};
React.useEffect(() => {
handleChange(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
return (
<Grid container spacing={2}>
<Grid item xs={6}>
<Video.Size
value={settings.resize}
label={<Trans>Resize</Trans>}
customLabel={<Trans>Custom size</Trans>}
onChange={update('resize')}
allowCustom={true}
allowAuto={true}
/>
</Grid>
<Grid item xs={6}>
<Video.GPU value={settings.gpu} onChange={update('gpu')} />
</Grid>
<Grid item xs={12}></Grid>
</Grid>
);
}
const coder = 'hevc_cuvid';

View File

@ -1,9 +1,15 @@
import React from 'react';
import Grid from '@mui/material/Grid';
import { Trans } from '@lingui/macro';
import Helper from '../../helper';
import Video from '../../settings/Video';
function init(initialState) {
const state = {
gpu: '0',
resize: 'auto',
...initialState,
};
@ -14,9 +20,15 @@ function createMapping(settings, stream, skills) {
stream = Helper.InitStream(stream);
skills = Helper.InitSkills(skills);
let local = ['-c:v', 'mjpeg_cuvid', '-gpu', `${settings.gpu}`];
if (settings.resize !== 'auto') {
local.push('-resize', `${settings.resize}`);
}
const mapping = {
global: [],
local: ['-c:v', 'mjpeg_cuvid'],
local: local,
filter: [],
};
@ -38,12 +50,38 @@ function Coder({ stream = {}, settings = {}, skills = {}, onChange = function (s
onChange(newSettings, createMapping(newSettings, stream, skills), automatic);
};
const update = (what) => (event) => {
const newSettings = {
...settings,
[what]: event.target.value,
};
handleChange(newSettings);
};
React.useEffect(() => {
handleChange(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
return (
<Grid container spacing={2}>
<Grid item xs={6}>
<Video.Size
value={settings.resize}
label={<Trans>Resize</Trans>}
customLabel={<Trans>Custom size</Trans>}
onChange={update('resize')}
allowCustom={true}
allowAuto={true}
/>
</Grid>
<Grid item xs={6}>
<Video.GPU value={settings.gpu} onChange={update('gpu')} />
</Grid>
<Grid item xs={12}></Grid>
</Grid>
);
}
const coder = 'mjpeg_cuvid';

View File

@ -1,9 +1,15 @@
import React from 'react';
import Grid from '@mui/material/Grid';
import { Trans } from '@lingui/macro';
import Helper from '../../helper';
import Video from '../../settings/Video';
function init(initialState) {
const state = {
gpu: '0',
resize: 'auto',
...initialState,
};
@ -14,9 +20,15 @@ function createMapping(settings, stream, skills) {
stream = Helper.InitStream(stream);
skills = Helper.InitSkills(skills);
let local = ['-c:v', 'mpeg1_cuvid', '-gpu', `${settings.gpu}`];
if (settings.resize !== 'auto') {
local.push('-resize', `${settings.resize}`);
}
const mapping = {
global: [],
local: ['-c:v', 'mpeg1_cuvid'],
local: local,
filter: [],
};
@ -38,12 +50,38 @@ function Coder({ stream = {}, settings = {}, skills = {}, onChange = function (s
onChange(newSettings, createMapping(newSettings, stream, skills), automatic);
};
const update = (what) => (event) => {
const newSettings = {
...settings,
[what]: event.target.value,
};
handleChange(newSettings);
};
React.useEffect(() => {
handleChange(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
return (
<Grid container spacing={2}>
<Grid item xs={6}>
<Video.Size
value={settings.resize}
label={<Trans>Resize</Trans>}
customLabel={<Trans>Custom size</Trans>}
onChange={update('resize')}
allowCustom={true}
allowAuto={true}
/>
</Grid>
<Grid item xs={6}>
<Video.GPU value={settings.gpu} onChange={update('gpu')} />
</Grid>
<Grid item xs={12}></Grid>
</Grid>
);
}
const coder = 'mpeg1_cuvid';

View File

@ -1,9 +1,15 @@
import React from 'react';
import Grid from '@mui/material/Grid';
import { Trans } from '@lingui/macro';
import Helper from '../../helper';
import Video from '../../settings/Video';
function init(initialState) {
const state = {
gpu: '0',
resize: 'auto',
...initialState,
};
@ -14,9 +20,15 @@ function createMapping(settings, stream, skills) {
stream = Helper.InitStream(stream);
skills = Helper.InitSkills(skills);
let local = ['-c:v', 'mpeg2_cuvid', '-gpu', `${settings.gpu}`];
if (settings.resize !== 'auto') {
local.push('-resize', `${settings.resize}`);
}
const mapping = {
global: [],
local: ['-c:v', 'mpeg2_cuvid'],
local: local,
filter: [],
};
@ -38,12 +50,38 @@ function Coder({ stream = {}, settings = {}, skills = {}, onChange = function (s
onChange(newSettings, createMapping(newSettings, stream, skills), automatic);
};
const update = (what) => (event) => {
const newSettings = {
...settings,
[what]: event.target.value,
};
handleChange(newSettings);
};
React.useEffect(() => {
handleChange(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
return (
<Grid container spacing={2}>
<Grid item xs={6}>
<Video.Size
value={settings.resize}
label={<Trans>Resize</Trans>}
customLabel={<Trans>Custom size</Trans>}
onChange={update('resize')}
allowCustom={true}
allowAuto={true}
/>
</Grid>
<Grid item xs={6}>
<Video.GPU value={settings.gpu} onChange={update('gpu')} />
</Grid>
<Grid item xs={12}></Grid>
</Grid>
);
}
const coder = 'mpeg2_cuvid';

View File

@ -1,9 +1,15 @@
import React from 'react';
import Grid from '@mui/material/Grid';
import { Trans } from '@lingui/macro';
import Helper from '../../helper';
import Video from '../../settings/Video';
function init(initialState) {
const state = {
gpu: '0',
resize: 'auto',
...initialState,
};
@ -14,9 +20,15 @@ function createMapping(settings, stream, skills) {
stream = Helper.InitStream(stream);
skills = Helper.InitSkills(skills);
let local = ['-c:v', 'mpeg4_cuvid', '-gpu', `${settings.gpu}`];
if (settings.resize !== 'auto') {
local.push('-resize', `${settings.resize}`);
}
const mapping = {
global: [],
local: ['-c:v', 'mpeg4_cuvid'],
local: local,
filter: [],
};
@ -38,12 +50,38 @@ function Coder({ stream = {}, settings = {}, skills = {}, onChange = function (s
onChange(newSettings, createMapping(newSettings, stream, skills), automatic);
};
const update = (what) => (event) => {
const newSettings = {
...settings,
[what]: event.target.value,
};
handleChange(newSettings);
};
React.useEffect(() => {
handleChange(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
return (
<Grid container spacing={2}>
<Grid item xs={6}>
<Video.Size
value={settings.resize}
label={<Trans>Resize</Trans>}
customLabel={<Trans>Custom size</Trans>}
onChange={update('resize')}
allowCustom={true}
allowAuto={true}
/>
</Grid>
<Grid item xs={6}>
<Video.GPU value={settings.gpu} onChange={update('gpu')} />
</Grid>
<Grid item xs={12}></Grid>
</Grid>
);
}
const coder = 'mpeg4_cuvid';

View File

@ -1,9 +1,13 @@
import React from 'react';
import Grid from '@mui/material/Grid';
import Helper from '../../helper';
import Video from '../../settings/Video';
function init(initialState) {
const state = {
gpu: '0',
...initialState,
};
@ -16,7 +20,7 @@ function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-hwaccel', 'cuda', '-hwaccel_output_format', 'cuda'],
local: ['-hwaccel', 'cuda', '-hwaccel_output_format', 'nv12', '-hwaccel_device', `${settings.gpu}`],
filter: [],
};
@ -38,12 +42,28 @@ function Coder({ stream = {}, settings = {}, skills = {}, onChange = function (s
onChange(newSettings, createMapping(newSettings, stream, skills), automatic);
};
const update = (what) => (event) => {
const newSettings = {
...settings,
[what]: event.target.value,
};
handleChange(newSettings);
};
React.useEffect(() => {
handleChange(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
return (
<Grid container spacing={2}>
<Grid item xs={6}>
<Video.GPU value={settings.gpu} onChange={update('gpu')} />
</Grid>
<Grid item xs={12}></Grid>
</Grid>
);
}
// -hwaccel cuda -hwaccel_output_format cuda

View File

@ -1,9 +1,15 @@
import React from 'react';
import Grid from '@mui/material/Grid';
import { Trans } from '@lingui/macro';
import Helper from '../../helper';
import Video from '../../settings/Video';
function init(initialState) {
const state = {
gpu: '0',
resize: 'auto',
...initialState,
};
@ -14,9 +20,15 @@ function createMapping(settings, stream, skills) {
stream = Helper.InitStream(stream);
skills = Helper.InitSkills(skills);
let local = ['-c:v', 'vc1_cuvid', '-gpu', `${settings.gpu}`];
if (settings.resize !== 'auto') {
local.push('-resize', `${settings.resize}`);
}
const mapping = {
global: [],
local: ['-c:v', 'vc1_cuvid'],
local: local,
filter: [],
};
@ -38,12 +50,38 @@ function Coder({ stream = {}, settings = {}, skills = {}, onChange = function (s
onChange(newSettings, createMapping(newSettings, stream, skills), automatic);
};
const update = (what) => (event) => {
const newSettings = {
...settings,
[what]: event.target.value,
};
handleChange(newSettings);
};
React.useEffect(() => {
handleChange(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
return (
<Grid container spacing={2}>
<Grid item xs={6}>
<Video.Size
value={settings.resize}
label={<Trans>Resize</Trans>}
customLabel={<Trans>Custom size</Trans>}
onChange={update('resize')}
allowCustom={true}
allowAuto={true}
/>
</Grid>
<Grid item xs={6}>
<Video.GPU value={settings.gpu} onChange={update('gpu')} />
</Grid>
<Grid item xs={12}></Grid>
</Grid>
);
}
const coder = 'vc1_cuvid';

View File

@ -1,9 +1,15 @@
import React from 'react';
import Grid from '@mui/material/Grid';
import { Trans } from '@lingui/macro';
import Helper from '../../helper';
import Video from '../../settings/Video';
function init(initialState) {
const state = {
gpu: '0',
resize: 'auto',
...initialState,
};
@ -14,9 +20,15 @@ function createMapping(settings, stream, skills) {
stream = Helper.InitStream(stream);
skills = Helper.InitSkills(skills);
let local = ['-c:v', 'vp8_cuvid', '-gpu', `${settings.gpu}`];
if (settings.resize !== 'auto') {
local.push('-resize', `${settings.resize}`);
}
const mapping = {
global: [],
local: ['-c:v', 'vp8_cuvid'],
local: local,
filter: [],
};
@ -38,12 +50,38 @@ function Coder({ stream = {}, settings = {}, skills = {}, onChange = function (s
onChange(newSettings, createMapping(newSettings, stream, skills), automatic);
};
const update = (what) => (event) => {
const newSettings = {
...settings,
[what]: event.target.value,
};
handleChange(newSettings);
};
React.useEffect(() => {
handleChange(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
return (
<Grid container spacing={2}>
<Grid item xs={6}>
<Video.Size
value={settings.resize}
label={<Trans>Resize</Trans>}
customLabel={<Trans>Custom size</Trans>}
onChange={update('resize')}
allowCustom={true}
allowAuto={true}
/>
</Grid>
<Grid item xs={6}>
<Video.GPU value={settings.gpu} onChange={update('gpu')} />
</Grid>
<Grid item xs={12}></Grid>
</Grid>
);
}
const coder = 'vp8_cuvid';

View File

@ -1,9 +1,15 @@
import React from 'react';
import Grid from '@mui/material/Grid';
import { Trans } from '@lingui/macro';
import Helper from '../../helper';
import Video from '../../settings/Video';
function init(initialState) {
const state = {
gpu: '0',
resize: 'auto',
...initialState,
};
@ -14,9 +20,15 @@ function createMapping(settings, stream, skills) {
stream = Helper.InitStream(stream);
skills = Helper.InitSkills(skills);
let local = ['-c:v', 'vp9_cuvid', '-gpu', `${settings.gpu}`];
if (settings.resize !== 'auto') {
local.push('-resize', `${settings.resize}`);
}
const mapping = {
global: [],
local: ['-c:v', 'vp9_cuvid'],
local: local,
filter: [],
};
@ -38,12 +50,38 @@ function Coder({ stream = {}, settings = {}, skills = {}, onChange = function (s
onChange(newSettings, createMapping(newSettings, stream, skills), automatic);
};
const update = (what) => (event) => {
const newSettings = {
...settings,
[what]: event.target.value,
};
handleChange(newSettings);
};
React.useEffect(() => {
handleChange(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
return (
<Grid container spacing={2}>
<Grid item xs={6}>
<Video.Size
value={settings.resize}
label={<Trans>Resize</Trans>}
customLabel={<Trans>Custom size</Trans>}
onChange={update('resize')}
allowCustom={true}
allowAuto={true}
/>
</Grid>
<Grid item xs={6}>
<Video.GPU value={settings.gpu} onChange={update('gpu')} />
</Grid>
<Grid item xs={12}></Grid>
</Grid>
);
}
const coder = 'vp9_cuvid';