Skip to content

Commit

Permalink
Add GPU selector for decoding and optional resizing for cuvid
Browse files Browse the repository at this point in the history
  • Loading branch information
ioppermann committed Nov 26, 2024
1 parent 75633bf commit 9aff56f
Show file tree
Hide file tree
Showing 11 changed files with 384 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/misc/coders/Decoders/video/av1_cuvid.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Helper from '../../helper';

function init(initialState) {
const state = {
gpu: '0',
resize: 'auto',
...initialState,
};

Expand Down
42 changes: 40 additions & 2 deletions src/misc/coders/Decoders/video/h264_cuvid.js
Original file line number Diff line number Diff line change
@@ -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,
};

Expand All @@ -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: [],
};

Expand All @@ -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 ...
Expand Down
42 changes: 40 additions & 2 deletions src/misc/coders/Decoders/video/hevc_cuvid.js
Original file line number Diff line number Diff line change
@@ -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,
};

Expand All @@ -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: [],
};

Expand All @@ -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';
Expand Down
42 changes: 40 additions & 2 deletions src/misc/coders/Decoders/video/mjpeg_cuvid.js
Original file line number Diff line number Diff line change
@@ -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,
};

Expand All @@ -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: [],
};

Expand All @@ -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';
Expand Down
42 changes: 40 additions & 2 deletions src/misc/coders/Decoders/video/mpeg1_cuvid.js
Original file line number Diff line number Diff line change
@@ -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,
};

Expand All @@ -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: [],
};

Expand All @@ -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';
Expand Down
42 changes: 40 additions & 2 deletions src/misc/coders/Decoders/video/mpeg2_cuvid.js
Original file line number Diff line number Diff line change
@@ -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,
};

Expand All @@ -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: [],
};

Expand All @@ -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';
Expand Down
Loading

0 comments on commit 9aff56f

Please sign in to comment.