mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-10 05:05:26 +03:00
preserve aspect ratio
This commit is contained in:
parent
28158b958e
commit
048dae3182
@ -37,7 +37,11 @@ export default function BirdseyeLivePlayer({
|
|||||||
} else if (liveMode == "jsmpeg") {
|
} else if (liveMode == "jsmpeg") {
|
||||||
return (
|
return (
|
||||||
<div className={`max-w-[${birdseyeConfig.width}px]`}>
|
<div className={`max-w-[${birdseyeConfig.width}px]`}>
|
||||||
<JSMpegPlayer camera="birdseye" />
|
<JSMpegPlayer
|
||||||
|
camera="birdseye"
|
||||||
|
width={birdseyeConfig.width}
|
||||||
|
height={birdseyeConfig.height}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -6,9 +6,16 @@ import { useEffect, useRef } from "react";
|
|||||||
type JSMpegPlayerProps = {
|
type JSMpegPlayerProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
camera: string;
|
camera: string;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function JSMpegPlayer({ camera, className }: JSMpegPlayerProps) {
|
export default function JSMpegPlayer({
|
||||||
|
camera,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
className,
|
||||||
|
}: JSMpegPlayerProps) {
|
||||||
const url = `${baseUrl.replace(/^http/, "ws")}live/jsmpeg/${camera}`;
|
const url = `${baseUrl.replace(/^http/, "ws")}live/jsmpeg/${camera}`;
|
||||||
const playerRef = useRef<HTMLDivElement | null>(null);
|
const playerRef = useRef<HTMLDivElement | null>(null);
|
||||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||||
@ -38,7 +45,11 @@ export default function JSMpegPlayer({ camera, className }: JSMpegPlayerProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className} ref={containerRef}>
|
<div className={className} ref={containerRef}>
|
||||||
<div ref={playerRef} className="jsmpeg size-full" />
|
<div
|
||||||
|
ref={playerRef}
|
||||||
|
className="jsmpeg size-full"
|
||||||
|
style={{ aspectRatio: width / height }}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,8 @@ export default function LivePlayer({
|
|||||||
|
|
||||||
// camera live state
|
// camera live state
|
||||||
|
|
||||||
const liveMode = useCameraLiveMode(cameraConfig, preferredLiveMode);
|
// const liveMode = useCameraLiveMode(cameraConfig, preferredLiveMode);
|
||||||
|
const liveMode = "jsmpeg";
|
||||||
|
|
||||||
const [liveReady, setLiveReady] = useState(false);
|
const [liveReady, setLiveReady] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -124,6 +125,8 @@ export default function LivePlayer({
|
|||||||
<JSMpegPlayer
|
<JSMpegPlayer
|
||||||
className="size-full flex justify-center rounded-2xl overflow-hidden"
|
className="size-full flex justify-center rounded-2xl overflow-hidden"
|
||||||
camera={cameraConfig.name}
|
camera={cameraConfig.name}
|
||||||
|
width={cameraConfig.detect.width}
|
||||||
|
height={cameraConfig.detect.height}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user