Fix mjpeg api (#14138)

This commit is contained in:
Nicolas Mowen 2024-10-03 07:33:06 -06:00 committed by GitHub
parent e5e196bd7f
commit 0f2cff5078
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,7 +14,7 @@ import numpy as np
import pytz import pytz
from fastapi import APIRouter, Path, Query, Request, Response from fastapi import APIRouter, Path, Query, Request, Response
from fastapi.params import Depends from fastapi.params import Depends
from fastapi.responses import FileResponse, JSONResponse from fastapi.responses import FileResponse, JSONResponse, StreamingResponse
from pathvalidate import sanitize_filename from pathvalidate import sanitize_filename
from peewee import DoesNotExist, fn from peewee import DoesNotExist, fn
from tzlocal import get_localzone_name from tzlocal import get_localzone_name
@ -44,7 +44,7 @@ logger = logging.getLogger(__name__)
router = APIRouter(tags=[Tags.media]) router = APIRouter(tags=[Tags.media])
@router.get("{camera_name}") @router.get("/{camera_name}")
def mjpeg_feed( def mjpeg_feed(
request: Request, request: Request,
camera_name: str, camera_name: str,
@ -60,7 +60,7 @@ def mjpeg_feed(
} }
if camera_name in request.app.frigate_config.cameras: if camera_name in request.app.frigate_config.cameras:
# return a multipart response # return a multipart response
return Response( return StreamingResponse(
imagestream( imagestream(
request.app.detected_frames_processor, request.app.detected_frames_processor,
camera_name, camera_name,