From 163025c1f24aef0a06e67bac7ec4c2e416f82f95 Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Sun, 31 Jan 2021 15:03:31 -0800 Subject: [PATCH] fix(app): reduce JPEG quality to drastically improve size --- frigate/http.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frigate/http.py b/frigate/http.py index 60c4ce539..998d42bc1 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -236,7 +236,7 @@ def best(camera_name, label): width = int(height*best_frame.shape[1]/best_frame.shape[0]) best_frame = cv2.resize(best_frame, dsize=(width, height), interpolation=cv2.INTER_AREA) - ret, jpg = cv2.imencode('.jpg', best_frame) + ret, jpg = cv2.imencode('.jpg', best_frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70]) response = make_response(jpg.tobytes()) response.headers['Content-Type'] = 'image/jpg' return response @@ -283,7 +283,7 @@ def latest_frame(camera_name): frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_AREA) - ret, jpg = cv2.imencode('.jpg', frame) + ret, jpg = cv2.imencode('.jpg', frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70]) response = make_response(jpg.tobytes()) response.headers['Content-Type'] = 'image/jpg' return response @@ -301,6 +301,6 @@ def imagestream(detected_frames_processor, camera_name, fps, height, draw_option width = int(height*frame.shape[1]/frame.shape[0]) frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_LINEAR) - ret, jpg = cv2.imencode('.jpg', frame) + ret, jpg = cv2.imencode('.jpg', frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70]) yield (b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + jpg.tobytes() + b'\r\n\r\n')