ESP32-CAM stream while writing to SD card?

Trifusion
Posts: 2
Joined: Thu Jan 27, 2022 3:01 am

ESP32-CAM stream while writing to SD card?

Postby Trifusion » Thu Jan 27, 2022 3:12 am

I would like to use an ESP32-CAM with a simple web browser that streams low res (low bandwidth) video and can write high res video to the onboard SD card. I can find examples of one or the other other but not code that does both at the same time at different resolutions. Is this possible? Is anyone aware of some sample code for this? Was hoping to know before I try and write code for this. Thank you.

alanesq
Posts: 84
Joined: Thu Dec 14, 2017 8:38 pm

Re: ESP32-CAM stream while writing to SD card?

Postby alanesq » Thu Jan 27, 2022 7:24 am

Hi,
I think the limiting factor will be how fast data can be written to the sd card
This sketch is the best I have seen for recording video but the camera can capture the images much faster than they can be written to the sd card (at least when I tried it)
https://github.com/mtnbkr88/ESP32CAMVideoRecorder

To switch resolution I think you will need to de-init the camera and restart it in the new mode which takes a long time.
I have a security camera sketch which uses a small greyscale image to detect movement and when detected switches the camera to higher res to capture an image but even in this application there is a significant delay between motion detected and hi-res image captured

Trifusion
Posts: 2
Joined: Thu Jan 27, 2022 3:01 am

Re: ESP32-CAM stream while writing to SD card?

Postby Trifusion » Thu Jan 27, 2022 10:11 am

I can't find any docs for the camera object most of the libraries are using but from what you are saying I am guessing it is hardware based and thus a singleton. I was hoping it was software based and that i could possibly create two camera objects, one for each resolution.

From what you are saying I think my best bet might be set the res high and down sample it for streaming but write out high res to SD when triggered. I worry about how to handle the latency of SD writes and streaming in a way that one process does not block the other. Either way I think I will try and take advantage of the dual core of the ESP32-CAM.

Did you try using xTaskCreatePinnedToCore() to run a second camera object on a different core? If the camera object is not a singleton I was thinking I could just monitor one of the GPIO pins and use that as a very simple global variable to pass a signal to start/stop recording between the cores? If it is a singleton I could use one core for streaming and the other for writing to the SD. Any thoughts on this approach as well as if a second camera object can be created or it's a singleton?

Thank you

Who is online

Users browsing this forum: No registered users and 103 guests