From 8ea0daab6903f453a5ce00beb254b728cd23258a Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sun, 7 Feb 2021 17:03:02 -0800 Subject: [PATCH] Add width+height resizing to variant settings. Closes https://github.com/owncast/owncast/issues/700 --- web/components/config/video-variant-form.tsx | 58 +++++++++++++++++--- web/types/config-section.ts | 3 + web/utils/config-constants.tsx | 2 + 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/web/components/config/video-variant-form.tsx b/web/components/config/video-variant-form.tsx index 1d85253a4..0d850f618 100644 --- a/web/components/config/video-variant-form.tsx +++ b/web/components/config/video-variant-form.tsx @@ -1,7 +1,8 @@ // This content populates the video variant modal, which is spawned from the variants table. import React from 'react'; import { Slider, Switch, Collapse } from 'antd'; -import { FieldUpdaterFunc, VideoVariant } from '../../types/config-section'; +import { FieldUpdaterFunc, VideoVariant, UpdateArgs } from '../../types/config-section'; +import TextField from './form-textfield'; import { DEFAULT_VARIANT_STATE } from '../../utils/config-constants'; import InfoTip from '../info-tip'; import CPUUsageSelector from './cpu-usage'; @@ -39,6 +40,20 @@ const VIDEO_VARIANT_DEFAULTS = { audioPassthrough: { tip: 'If No is selected, then you should set your desired Audio Bitrate.', }, + scaledWidth: { + fieldName: 'scaledWidth', + label: 'Resized Width', + maxLength: 4, + placeholder: '1080', + tip: "Optionally resize this content's width.", + }, + scaledHeight: { + fieldName: 'scaledHeight', + label: 'Resized Height', + maxLength: 4, + placeholder: '720', + tip: "Optionally resize this content's height.", + }, }; interface VideoVariantFormProps { @@ -62,7 +77,21 @@ export default function VideoVariantForm({ const handleVideoCpuUsageLevelChange = (value: number) => { onUpdateField({ fieldName: 'cpuUsageLevel', value }); }; + const handleScaledWidthChanged = (args: UpdateArgs) => { + const value = Number(args.value); + if (!isNaN(value)) { + return; + } + onUpdateField({ fieldName: 'scaledWidth', value: value }); + }; + const handleScaledHeightChanged = (args: UpdateArgs) => { + const value = Number(args.value); + if (!isNaN(value)) { + return; + } + onUpdateField({ fieldName: 'scaledHeight', value: value }); + }; const framerateDefaults = VIDEO_VARIANT_DEFAULTS.framerate; const framerateMin = framerateDefaults.min; const framerateMax = framerateDefaults.max; @@ -145,14 +174,29 @@ export default function VideoVariantForm({ -
-
-
-
- -
Touch if you dare.
+
+ Resizing your content will take additional resources on your server. If you wish to + optionally resize your output for this stream variant then you should either set the + width or the height to keep your aspect ratio. +
+
+ +
+
+ +
{/* FRAME RATE FIELD */}
diff --git a/web/types/config-section.ts b/web/types/config-section.ts index e85036397..05484c9df 100644 --- a/web/types/config-section.ts +++ b/web/types/config-section.ts @@ -56,6 +56,9 @@ export interface VideoVariant { audioBitrate: number; videoPassthrough: boolean; videoBitrate: number; + + scaledWidth: number; + scaledHeight: number; } export interface VideoSettingsFields { latencyLevel: number; diff --git a/web/utils/config-constants.tsx b/web/utils/config-constants.tsx index 88223e727..bbca05014 100644 --- a/web/utils/config-constants.tsx +++ b/web/utils/config-constants.tsx @@ -168,6 +168,8 @@ export const DEFAULT_VARIANT_STATE: VideoVariant = { audioPassthrough: true, // if false, then CAN set audiobitrate audioBitrate: 0, cpuUsageLevel: 3, + scaledHeight: null, + scaledWidth: null, }; export const DEFAULT_SOCIAL_HANDLE: SocialHandle = {