From 9aff56f76e4556fd5900d06e23403df9d91752d7 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Tue, 26 Nov 2024 14:51:02 +0100 Subject: [PATCH] Add GPU selector for decoding and optional resizing for cuvid --- src/misc/coders/Decoders/video/av1_cuvid.js | 2 + src/misc/coders/Decoders/video/h264_cuvid.js | 42 ++++++++++++++++++- src/misc/coders/Decoders/video/hevc_cuvid.js | 42 ++++++++++++++++++- src/misc/coders/Decoders/video/mjpeg_cuvid.js | 42 ++++++++++++++++++- src/misc/coders/Decoders/video/mpeg1_cuvid.js | 42 ++++++++++++++++++- src/misc/coders/Decoders/video/mpeg2_cuvid.js | 42 ++++++++++++++++++- src/misc/coders/Decoders/video/mpeg4_cuvid.js | 42 ++++++++++++++++++- src/misc/coders/Decoders/video/nvdec.js | 24 ++++++++++- src/misc/coders/Decoders/video/vc1_cuvid.js | 42 ++++++++++++++++++- src/misc/coders/Decoders/video/vp8_cuvid.js | 42 ++++++++++++++++++- src/misc/coders/Decoders/video/vp9_cuvid.js | 42 ++++++++++++++++++- 11 files changed, 384 insertions(+), 20 deletions(-) diff --git a/src/misc/coders/Decoders/video/av1_cuvid.js b/src/misc/coders/Decoders/video/av1_cuvid.js index d718382..3bce062 100644 --- a/src/misc/coders/Decoders/video/av1_cuvid.js +++ b/src/misc/coders/Decoders/video/av1_cuvid.js @@ -4,6 +4,8 @@ import Helper from '../../helper'; function init(initialState) { const state = { + gpu: '0', + resize: 'auto', ...initialState, }; diff --git a/src/misc/coders/Decoders/video/h264_cuvid.js b/src/misc/coders/Decoders/video/h264_cuvid.js index f3c0a37..5466627 100644 --- a/src/misc/coders/Decoders/video/h264_cuvid.js +++ b/src/misc/coders/Decoders/video/h264_cuvid.js @@ -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 ( + + + Resize} + customLabel={Custom size} + onChange={update('resize')} + allowCustom={true} + allowAuto={true} + /> + + + + + + + ); } // -c:v h264_cuvid -i ... diff --git a/src/misc/coders/Decoders/video/hevc_cuvid.js b/src/misc/coders/Decoders/video/hevc_cuvid.js index 8c71699..bfe68a9 100644 --- a/src/misc/coders/Decoders/video/hevc_cuvid.js +++ b/src/misc/coders/Decoders/video/hevc_cuvid.js @@ -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 ( + + + Resize} + customLabel={Custom size} + onChange={update('resize')} + allowCustom={true} + allowAuto={true} + /> + + + + + + + ); } const coder = 'hevc_cuvid'; diff --git a/src/misc/coders/Decoders/video/mjpeg_cuvid.js b/src/misc/coders/Decoders/video/mjpeg_cuvid.js index e06fb37..02885fe 100644 --- a/src/misc/coders/Decoders/video/mjpeg_cuvid.js +++ b/src/misc/coders/Decoders/video/mjpeg_cuvid.js @@ -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 ( + + + Resize} + customLabel={Custom size} + onChange={update('resize')} + allowCustom={true} + allowAuto={true} + /> + + + + + + + ); } const coder = 'mjpeg_cuvid'; diff --git a/src/misc/coders/Decoders/video/mpeg1_cuvid.js b/src/misc/coders/Decoders/video/mpeg1_cuvid.js index 6f7fc5f..7c6a58d 100644 --- a/src/misc/coders/Decoders/video/mpeg1_cuvid.js +++ b/src/misc/coders/Decoders/video/mpeg1_cuvid.js @@ -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 ( + + + Resize} + customLabel={Custom size} + onChange={update('resize')} + allowCustom={true} + allowAuto={true} + /> + + + + + + + ); } const coder = 'mpeg1_cuvid'; diff --git a/src/misc/coders/Decoders/video/mpeg2_cuvid.js b/src/misc/coders/Decoders/video/mpeg2_cuvid.js index a22151b..88288d8 100644 --- a/src/misc/coders/Decoders/video/mpeg2_cuvid.js +++ b/src/misc/coders/Decoders/video/mpeg2_cuvid.js @@ -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 ( + + + Resize} + customLabel={Custom size} + onChange={update('resize')} + allowCustom={true} + allowAuto={true} + /> + + + + + + + ); } const coder = 'mpeg2_cuvid'; diff --git a/src/misc/coders/Decoders/video/mpeg4_cuvid.js b/src/misc/coders/Decoders/video/mpeg4_cuvid.js index da18c77..32c1e2d 100644 --- a/src/misc/coders/Decoders/video/mpeg4_cuvid.js +++ b/src/misc/coders/Decoders/video/mpeg4_cuvid.js @@ -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 ( + + + Resize} + customLabel={Custom size} + onChange={update('resize')} + allowCustom={true} + allowAuto={true} + /> + + + + + + + ); } const coder = 'mpeg4_cuvid'; diff --git a/src/misc/coders/Decoders/video/nvdec.js b/src/misc/coders/Decoders/video/nvdec.js index 6ae767d..8efc7c9 100644 --- a/src/misc/coders/Decoders/video/nvdec.js +++ b/src/misc/coders/Decoders/video/nvdec.js @@ -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 ( + + + + + + + ); } // -hwaccel cuda -hwaccel_output_format cuda diff --git a/src/misc/coders/Decoders/video/vc1_cuvid.js b/src/misc/coders/Decoders/video/vc1_cuvid.js index 3fcef26..ca8a0e0 100644 --- a/src/misc/coders/Decoders/video/vc1_cuvid.js +++ b/src/misc/coders/Decoders/video/vc1_cuvid.js @@ -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 ( + + + Resize} + customLabel={Custom size} + onChange={update('resize')} + allowCustom={true} + allowAuto={true} + /> + + + + + + + ); } const coder = 'vc1_cuvid'; diff --git a/src/misc/coders/Decoders/video/vp8_cuvid.js b/src/misc/coders/Decoders/video/vp8_cuvid.js index a8a9fe2..a61dc49 100644 --- a/src/misc/coders/Decoders/video/vp8_cuvid.js +++ b/src/misc/coders/Decoders/video/vp8_cuvid.js @@ -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 ( + + + Resize} + customLabel={Custom size} + onChange={update('resize')} + allowCustom={true} + allowAuto={true} + /> + + + + + + + ); } const coder = 'vp8_cuvid'; diff --git a/src/misc/coders/Decoders/video/vp9_cuvid.js b/src/misc/coders/Decoders/video/vp9_cuvid.js index 1dff10a..bdb333b 100644 --- a/src/misc/coders/Decoders/video/vp9_cuvid.js +++ b/src/misc/coders/Decoders/video/vp9_cuvid.js @@ -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 ( + + + Resize} + customLabel={Custom size} + onChange={update('resize')} + allowCustom={true} + allowAuto={true} + /> + + + + + + + ); } const coder = 'vp9_cuvid';