From c14f3c390263b1d40c4adb0fb4aa552c9ea15c6f Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 15 Mar 2024 17:28:57 -0600 Subject: [PATCH] Fix frigate+ submit and recordings layouts for portrait cameras (#10486) * Fix plus submission dialog * Different layout for portrait recordings * Fix now preview found pulsing * Fix bug with uneven milliseconds * Improve consistency of video scaling --- web/src/components/player/HlsVideoPlayer.tsx | 6 ++- web/src/components/player/PreviewPlayer.tsx | 2 +- .../player/dynamic/DynamicVideoPlayer.tsx | 23 ++++++++---- web/src/pages/Events.tsx | 1 + web/src/pages/SubmitPlus.tsx | 22 ++++++++++- web/src/views/events/RecordingView.tsx | 37 ++++++++++++++----- 6 files changed, 70 insertions(+), 21 deletions(-) diff --git a/web/src/components/player/HlsVideoPlayer.tsx b/web/src/components/player/HlsVideoPlayer.tsx index 4492bae43..fd0e79db0 100644 --- a/web/src/components/player/HlsVideoPlayer.tsx +++ b/web/src/components/player/HlsVideoPlayer.tsx @@ -59,6 +59,7 @@ export default function HlsVideoPlayer({ const hlsRef = useRef(); const [useHlsCompat, setUseHlsCompat] = useState(false); + const [loadedMetadata, setLoadedMetadata] = useState(false); useEffect(() => { if (!videoRef.current) { @@ -153,7 +154,7 @@ export default function HlsVideoPlayer({ return (
{ @@ -174,7 +175,7 @@ export default function HlsVideoPlayer({ {!loaded && } {cameraPreviews && !currentPreview && ( -
+
No Preview Found
)} diff --git a/web/src/components/player/dynamic/DynamicVideoPlayer.tsx b/web/src/components/player/dynamic/DynamicVideoPlayer.tsx index 3c656a4a7..c869e516d 100644 --- a/web/src/components/player/dynamic/DynamicVideoPlayer.tsx +++ b/web/src/components/player/dynamic/DynamicVideoPlayer.tsx @@ -38,16 +38,23 @@ export default function DynamicVideoPlayer({ const { data: config } = useSWR("config"); // playback behavior - const wideVideo = useMemo(() => { + + const grow = useMemo(() => { if (!config) { - return false; + return "aspect-video"; } - return ( + const aspectRatio = config.cameras[camera].detect.width / - config.cameras[camera].detect.height > - 1.7 - ); + config.cameras[camera].detect.height; + + if (aspectRatio > 2) { + return ""; + } else if (aspectRatio < 16 / 9) { + return "aspect-tall"; + } else { + return "aspect-video"; + } }, [camera, config]); // controlling playback @@ -163,7 +170,7 @@ export default function DynamicVideoPlayer({ className={`w-full relative ${isScrubbing || isLoading ? "hidden" : "visible"}`} >
("config"); + // filters const [selectedCameras, setSelectedCameras] = useState(); @@ -45,6 +47,24 @@ export default function SubmitPlus() { ]); const [upload, setUpload] = useState(); + const grow = useMemo(() => { + if (!config || !upload) { + return ""; + } + + const camera = config.cameras[upload.camera]; + + if (!camera) { + return ""; + } + + if (camera.detect.width / camera.detect.height < 16 / 9) { + return "aspect-video object-contain"; + } + + return ""; + }, [config, upload]); + const onSubmitToPlus = useCallback( async (falsePositive: boolean) => { if (!upload) { @@ -102,7 +122,7 @@ export default function SubmitPlus() { {`${upload?.label}`} diff --git a/web/src/views/events/RecordingView.tsx b/web/src/views/events/RecordingView.tsx index 60b8e58a8..d7220c7ab 100644 --- a/web/src/views/events/RecordingView.tsx +++ b/web/src/views/events/RecordingView.tsx @@ -170,21 +170,34 @@ export function DesktopRecordingView({ : null, ); - const grow = useMemo(() => { + const mainCameraAspect = useMemo(() => { if (!config) { - return "aspect-video"; + return "normal"; } const aspectRatio = config.cameras[mainCamera].detect.width / config.cameras[mainCamera].detect.height; + if (aspectRatio > 2) { - return "aspect-wide"; + return "wide"; + } else if (aspectRatio < 16 / 9) { + return "tall"; } else { - return "aspect-video"; + return "normal"; } }, [config, mainCamera]); + const grow = useMemo(() => { + if (mainCameraAspect == "wide") { + return "w-full aspect-wide"; + } else if (mainCameraAspect == "tall") { + return "h-full aspect-tall"; + } else { + return "w-full aspect-video"; + } + }, [mainCameraAspect]); + return (