owncast/web/pages/config-video.tsx

115 lines
2.5 KiB
TypeScript
Raw Normal View History

import React, { useContext } from 'react';
2020-10-29 20:16:13 +03:00
import { Table, Typography } from 'antd';
import { ServerStatusContext } from '../utils/server-status-context';
2020-10-29 20:16:13 +03:00
const { Title } = Typography;
function VideoVariants({ config }) {
2020-11-01 10:01:37 +03:00
if (!config || !config.videoSettings) {
2020-10-29 20:16:13 +03:00
return null;
}
2021-01-03 13:13:28 +03:00
console.log(config.videoSettings)
2020-10-29 20:16:13 +03:00
const videoQualityColumns = [
{
title: "#",
dataIndex: "key",
key: "key"
},
2020-10-29 20:16:13 +03:00
{
title: "Video bitrate",
dataIndex: "videoBitrate",
key: "videoBitrate",
render: (bitrate) =>
!bitrate ? "Same as source" : `${bitrate} kbps`,
2020-10-29 20:16:13 +03:00
},
{
title: "Framerate",
dataIndex: "framerate",
key: "framerate",
render: (framerate) =>
!framerate ? "Same as source" : `${framerate} fps`,
2020-10-29 20:16:13 +03:00
},
{
title: "Encoder preset",
dataIndex: "encoderPreset",
key: "framerate",
render: (preset) =>
!preset ? "n/a" : preset,
2020-10-29 20:16:13 +03:00
},
{
title: "Audio bitrate",
dataIndex: "audioBitrate",
key: "audioBitrate",
render: (bitrate) =>
!bitrate ? "Same as source" : `${bitrate} kbps`,
2020-10-29 20:16:13 +03:00
},
];
const miscVideoSettingsColumns = [
{
title: "Name",
dataIndex: "name",
key: "name",
},
{
title: "Value",
dataIndex: "value",
key: "value",
},
];
const miscVideoSettings = [
{
name: "Segment length",
value: config.videoSettings.segmentLengthSeconds,
key: "segmentLength"
2020-10-29 20:16:13 +03:00
},
{
name: "Number of segments",
value: config.videoSettings.numberOfPlaylistItems,
key: "numberOfSegments"
2020-10-29 20:16:13 +03:00
},
];
const videoQualityVariantData = config.videoSettings.videoQualityVariants.map(function(variant, index) {
return {
key: index,
...variant
}
});
2020-10-29 20:16:13 +03:00
return (
<div>
<Title>Video configuration</Title>
<Table
pagination={false}
columns={videoQualityColumns}
dataSource={videoQualityVariantData}
2020-10-29 20:16:13 +03:00
/>
<Table
pagination={false}
columns={miscVideoSettingsColumns}
dataSource={miscVideoSettings}
rowKey={row => row.name}
2020-10-29 20:16:13 +03:00
/>
<br/>
<Title level={5}>Learn more about configuring Owncast <a href="https://owncast.online/docs/configuration">by visiting the documentation.</a></Title>
2020-10-29 20:16:13 +03:00
</div>
);
}
export default function VideoConfig() {
const serverStatusData = useContext(ServerStatusContext);
const { serverConfig: config } = serverStatusData || {};
2020-10-29 20:16:13 +03:00
return (
<div>
<VideoVariants config={config} />
</div>
);
}