perf: réduire la latence du flux MJPEG

- Pipeline 640x480@30fps au lieu de 1280x720@15fps
- appsink max-buffers=1 sync=false pour éliminer le buffering
- Suppression du time.sleep(0.066) dans generate_mjpeg

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-08 17:38:42 +02:00
parent cce7fe93b8
commit d416f82889

View File

@ -35,10 +35,10 @@ def capture_loop():
# Pipeline GStreamer pour CSI sur Pi Bookworm # Pipeline GStreamer pour CSI sur Pi Bookworm
pipeline = ( pipeline = (
"libcamerasrc ! " "libcamerasrc ! "
"video/x-raw,width=1280,height=720,framerate=15/1 ! " "video/x-raw,width=640,height=480,framerate=30/1 ! "
"videoconvert ! " "videoconvert ! "
"video/x-raw,format=BGR ! " "video/x-raw,format=BGR ! "
"appsink drop=1" "appsink drop=1 max-buffers=1 sync=false"
) )
cam = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER) cam = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)
@ -71,7 +71,6 @@ def generate_mjpeg():
+ jpeg.tobytes() + jpeg.tobytes()
+ b"\r\n" + b"\r\n"
) )
time.sleep(0.066)
@app.route("/") @app.route("/")
def index(): def index():