fix: timing flash + couleur idle LED + diagnostic auto-brightness
This commit is contained in:
@@ -191,26 +191,40 @@ class PhotoboothService:
|
||||
"""Tente de recuperer une frame JPEG du liveview de photobooth-app.
|
||||
|
||||
Essaie dans l'ordre :
|
||||
1. /api/stream/snapshot — endpoint snapshot direct (si disponible)
|
||||
2. /stream.mjpg — flux MJPEG classique, extrait la premiere frame
|
||||
3. /api/stream — flux MJPEG alternatif
|
||||
1. Endpoints snapshot direct (retour JPEG immédiat)
|
||||
2. Flux MJPEG — extrait la premiere frame
|
||||
|
||||
Retourne des bytes JPEG ou None si rien n'est disponible.
|
||||
"""
|
||||
# 1. Snapshot direct
|
||||
for path in ("/api/stream/snapshot",):
|
||||
# 1. Endpoints snapshot direct (differentes versions de photobooth-app)
|
||||
snapshot_paths = (
|
||||
"/api/stream/snapshot",
|
||||
"/api/video/preview/snapshot",
|
||||
"/api/livestream/snapshot",
|
||||
"/api/cam/stream/snapshot",
|
||||
)
|
||||
for path in snapshot_paths:
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=2.0) as client:
|
||||
r = await client.get(f"{self._base}{path}")
|
||||
if r.status_code == 200:
|
||||
ct = r.headers.get("content-type", "")
|
||||
if "jpeg" in ct or "image" in ct:
|
||||
logger.debug("Snapshot OK via %s", path)
|
||||
return r.content
|
||||
except Exception as e:
|
||||
logger.debug("Snapshot %s: %s", path, e)
|
||||
|
||||
# 2. Premiere frame d'un flux MJPEG
|
||||
for path in ("/stream.mjpg", "/api/stream"):
|
||||
# 2. Premiere frame d'un flux MJPEG (differentes versions)
|
||||
mjpeg_paths = (
|
||||
"/stream.mjpg",
|
||||
"/api/stream",
|
||||
"/api/video/stream",
|
||||
"/api/video/preview",
|
||||
"/api/livestream",
|
||||
"/livestream",
|
||||
)
|
||||
for path in mjpeg_paths:
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=3.0) as client:
|
||||
async with client.stream("GET", f"{self._base}{path}") as resp:
|
||||
@@ -223,12 +237,14 @@ class PhotoboothService:
|
||||
if start >= 0:
|
||||
end = buf.find(b"\xff\xd9", start)
|
||||
if end >= 0:
|
||||
logger.debug("MJPEG frame OK via %s", path)
|
||||
return buf[start:end + 2]
|
||||
if len(buf) > 500_000:
|
||||
break
|
||||
except Exception as e:
|
||||
logger.debug("MJPEG %s: %s", path, e)
|
||||
|
||||
logger.debug("Aucun endpoint liveview disponible sur %s", self._base)
|
||||
return None
|
||||
|
||||
async def close(self):
|
||||
|
||||
Reference in New Issue
Block a user