Use timestamp based recordings check instead of calendar

This commit is contained in:
Nicolas Mowen 2024-03-11 14:27:56 -06:00
parent f01bc18196
commit 0c15f21e2f
3 changed files with 27 additions and 27 deletions

View File

@ -38,11 +38,6 @@ export default function DynamicVideoPlayer({
}: DynamicVideoPlayerProps) { }: DynamicVideoPlayerProps) {
const apiHost = useApiHost(); const apiHost = useApiHost();
const { data: config } = useSWR<FrigateConfig>("config"); const { data: config } = useSWR<FrigateConfig>("config");
const timezone = useMemo(
() =>
config?.ui?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone,
[config],
);
// playback behavior // playback behavior
const wideVideo = useMemo(() => { const wideVideo = useMemo(() => {
@ -152,14 +147,8 @@ export default function DynamicVideoPlayer({
// initial state // initial state
const initialPlaybackSource = useMemo(() => { const initialPlaybackSource = useMemo(() => {
const date = new Date(timeRange.start * 1000);
return { return {
src: `${apiHost}vod/${date.getFullYear()}-${ src: `${apiHost}vod/${camera}/start/${timeRange.start}/end/${timeRange.end}/master.m3u8`,
date.getMonth() + 1
}/${date.getDate()}/${date.getHours()}/${camera}/${timezone.replaceAll(
"/",
",",
)}/master.m3u8`,
type: "application/vnd.apple.mpegurl", type: "application/vnd.apple.mpegurl",
}; };
// we only want to calculate this once // we only want to calculate this once
@ -222,13 +211,7 @@ export default function DynamicVideoPlayer({
return; return;
} }
const date = new Date(timeRange.start * 1000); const playbackUri = `${apiHost}vod/${camera}/start/${timeRange.start}/end/${timeRange.end}/master.m3u8`;
const playbackUri = `${apiHost}vod/${date.getFullYear()}-${
date.getMonth() + 1
}/${date.getDate()}/${date.getHours()}/${camera}/${timezone.replaceAll(
"/",
",",
)}/master.m3u8`;
controller.newPlayback({ controller.newPlayback({
recordings: recordings ?? [], recordings: recordings ?? [],
@ -436,7 +419,7 @@ export class DynamicVideoController {
const scrubResult = this.previewController.scrubToTimestamp(time); const scrubResult = this.previewController.scrubToTimestamp(time);
if (!scrubResult && saveIfNotReady) { if (!scrubResult && saveIfNotReady) {
//this.previewController.setNewPreviewStartTime(time); this.previewController.setNewPreviewStartTime(time);
} }
if (scrubResult && this.playerMode != "scrubbing") { if (scrubResult && this.playerMode != "scrubbing") {

View File

@ -11,6 +11,7 @@ import {
DropdownMenuRadioItem, DropdownMenuRadioItem,
DropdownMenuTrigger, DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"; } from "@/components/ui/dropdown-menu";
import { FrigateConfig } from "@/types/frigateConfig";
import { Preview } from "@/types/preview"; import { Preview } from "@/types/preview";
import { MotionData, ReviewSegment, ReviewSeverity } from "@/types/review"; import { MotionData, ReviewSegment, ReviewSeverity } from "@/types/review";
import { getChunkedTimeDay } from "@/utils/timelineUtil"; import { getChunkedTimeDay } from "@/utils/timelineUtil";
@ -37,6 +38,7 @@ export function DesktopRecordingView({
allCameras, allCameras,
allPreviews, allPreviews,
}: DesktopRecordingViewProps) { }: DesktopRecordingViewProps) {
const { data: config } = useSWR<FrigateConfig>("config");
const navigate = useNavigate(); const navigate = useNavigate();
const contentRef = useRef<HTMLDivElement | null>(null); const contentRef = useRef<HTMLDivElement | null>(null);
@ -162,6 +164,21 @@ export function DesktopRecordingView({
: null, : null,
); );
const grow = useMemo(() => {
if (!config) {
return "aspect-video";
}
const aspectRatio =
config.cameras[mainCamera].detect.width /
config.cameras[mainCamera].detect.height;
if (aspectRatio > 2) {
return "aspect-wide";
} else {
return "aspect-video";
}
}, [config, mainCamera]);
return ( return (
<div ref={contentRef} className="relative size-full"> <div ref={contentRef} className="relative size-full">
<Button <Button
@ -177,7 +194,7 @@ export function DesktopRecordingView({
<div className="flex flex-col h-full px-2 justify-end"> <div className="flex flex-col h-full px-2 justify-end">
<div key={mainCamera} className="flex justify-center mb-5"> <div key={mainCamera} className="flex justify-center mb-5">
<DynamicVideoPlayer <DynamicVideoPlayer
className="w-[85%]" className={`w-[85%] ${grow}`}
camera={mainCamera} camera={mainCamera}
timeRange={currentTimeRange} timeRange={currentTimeRange}
cameraPreviews={allPreviews ?? []} cameraPreviews={allPreviews ?? []}

View File

@ -12,24 +12,24 @@ export default defineConfig({
server: { server: {
proxy: { proxy: {
"/api": { "/api": {
target: "http://localhost:5000", target: "http://192.168.50.106:5000",
ws: true, ws: true,
}, },
"/vod": { "/vod": {
target: "http://localhost:5000", target: "http://192.168.50.106:5000",
}, },
"/clips": { "/clips": {
target: "http://localhost:5000", target: "http://192.168.50.106:5000",
}, },
"/exports": { "/exports": {
target: "http://localhost:5000", target: "http://192.168.50.106:5000",
}, },
"/ws": { "/ws": {
target: "ws://localhost:5000", target: "ws://192.168.50.106:5000",
ws: true, ws: true,
}, },
"/live": { "/live": {
target: "ws://localhost:5000", target: "ws://192.168.50.106:5000",
changeOrigin: true, changeOrigin: true,
ws: true, ws: true,
}, },