From e2b0faa0dd5d996d6ce694272234099e2d15aa90 Mon Sep 17 00:00:00 2001 From: Jannik Date: Wed, 3 Nov 2021 22:09:47 +0100 Subject: [PATCH] Add a recommendation in the admin to add a second, lower quality if only one is set (#356) * :sparkles: add recommendation box if only one, high-quality video variant is set (#1491) Related to: https://github.com/owncast/owncast/issues/1491 * Prettified Code! * Tweak the alert text slightly Co-authored-by: jeyemwey Co-authored-by: Gabe Kangas --- .../config/video-variants-table.tsx | 22 ++++++++++++++++++- web/utils/config-constants.tsx | 7 ++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/web/components/config/video-variants-table.tsx b/web/components/config/video-variants-table.tsx index 524cb22d8..a43835959 100644 --- a/web/components/config/video-variants-table.tsx +++ b/web/components/config/video-variants-table.tsx @@ -1,7 +1,7 @@ // Updating a variant will post ALL the variants in an array as an update to the API. import React, { useContext, useState } from 'react'; -import { Typography, Table, Modal, Button } from 'antd'; +import { Typography, Table, Modal, Button, Alert } from 'antd'; import { ColumnsType } from 'antd/lib/table'; import { DeleteOutlined } from '@ant-design/icons'; import { ServerStatusContext } from '../../utils/server-status-context'; @@ -15,6 +15,7 @@ import { RESET_TIMEOUT, postConfigUpdateToAPI, ENCODER_PRESET_TOOLTIPS, + ENCODER_RECOMMENDATION_THRESHOLD, } from '../../utils/config-constants'; import { createInputStatus, @@ -183,12 +184,31 @@ export default function CurrentVariantsTable() { ...variant, })); + const showSecondVariantRecommendation = (): boolean => { + if (videoQualityVariants.length !== 1) { + return false; + } + + const [variant] = videoQualityVariants; + + return ( + ENCODER_RECOMMENDATION_THRESHOLD.VIDEO_HEIGHT <= variant.scaledHeight || + ENCODER_RECOMMENDATION_THRESHOLD.VIDEO_BITRATE <= variant.videoBitrate + ); + }; + return ( <> Stream output + {showSecondVariantRecommendation() && ( + <> + + + )} +