From e6acdbe8a13cbe92b00603e79f25b8ed5bebb105 Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Sun, 6 Nov 2022 11:02:32 +0100 Subject: [PATCH 1/4] Grab frame before snapshot --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index 5a40f5c..9918c10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -149,6 +149,7 @@ void handle_snapshot() return; } + cam.run(); if (cam.getfb() == nullptr) { web_server.send(404, "text/plain", "Unable to obtain frame buffer from the camera"); From 11dfe22807d91fff2d0fe271219355f3fbec108c Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Sun, 6 Nov 2022 20:37:48 +0100 Subject: [PATCH 2/4] - Do not copy the framebuffer - Typo in logging --- src/main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9918c10..4aca079 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -150,19 +150,18 @@ void handle_snapshot() } cam.run(); - if (cam.getfb() == nullptr) + auto fb_len = cam.getSize(); + auto fb = (const char*)cam.getfb(); + if (fb == nullptr) { web_server.send(404, "text/plain", "Unable to obtain frame buffer from the camera"); return; } - auto fb_len = cam.getSize(); - auto fb = (const char *)memcpy(new uint8_t[fb_len], cam.getfb(), fb_len); web_server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); web_server.setContentLength(fb_len); web_server.send(200, "image/jpeg", ""); web_server.sendContent(fb, fb_len); - delete[] fb; } void handle_flash() @@ -220,7 +219,7 @@ void start_rtsp_server() camera_init_result = initialize_camera(); if (camera_init_result != ESP_OK) { - log_e("Failed to initialize camera: 0x%0xd. Type: %s, frame size: %s, frame buffers: %s, frame rate: %s ms, jpeg quality: %s", camera_init_result, camera_config_val, frame_size_val, frame_buffers_val, frame_duration_val, jpeg_quality_val); + log_e("Failed to initialize camera: 0x%0x. Type: %s, frame size: %s, frame buffers: %s, frame rate: %s ms, jpeg quality: %s", camera_init_result, camera_config_val, frame_size_val, frame_buffers_val, frame_duration_val, jpeg_quality_val); return; } From 370f3c805cca21d05d584b4ecc0ff95104c21642 Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Sun, 6 Nov 2022 20:44:50 +0100 Subject: [PATCH 3/4] - remove old frames from the frame buffer before sending snapshot --- src/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4aca079..586ea96 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -149,7 +149,11 @@ void handle_snapshot() return; } - cam.run(); + // Remove old images stored in the framebuffer + auto frame_buffers = atoi(frame_buffers_val); + while (frame_buffers--) + cam.run(); + auto fb_len = cam.getSize(); auto fb = (const char*)cam.getfb(); if (fb == nullptr) @@ -188,7 +192,6 @@ void on_config_saved() log_v("on_config_saved"); // Set flash led intensity analogWrite(LED_FLASH, atoi(flash_led_intensity_val)); - config_changed = true; } From fb8186d9f52cb5eab2659c67c8e66fb5193d4806 Mon Sep 17 00:00:00 2001 From: Hendrik Kuck Date: Sun, 13 Nov 2022 12:53:14 +0100 Subject: [PATCH 4/4] Update README.md fixed typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d40be19..fe548fa 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Easy configuration through the web interface. Flashing this software on a ESP32CAM module will make it a **RTSP streaming camera** server. The RTSP protocol is an industry standard and allows many CCTV systems and applications (like for example [VLC](https://www.videolan.org/vlc/)) to connect directly to the ESP32CAM camera stream. -It is also possible to to stream directly to a server using [ffmpeg](https://ffmpeg.org). +It is also possible to stream directly to a server using [ffmpeg](https://ffmpeg.org). This makes the module a camera server allowing recording and the stream can be stored on a disk and replayed later. This software supports the following ESP32-CAM (and alike) modules: