jameszah / ESP32-CAM-Video-Recorder

Video Recorder for ESP32-CAM with http server for config and ftp (or http) server to download video
GNU General Public License v3.0
453 stars 102 forks source link

Start / stop recordings without the Internet http #4

Closed jameszah closed 4 years ago

jameszah commented 4 years ago

Hey Dude,

How do I stop / start recordings without going through the internet http system -- like with a PIR or a button?

jameszah commented 4 years ago

Great question dude.

This little bit of code near the end of the setup() starts the recording.

You have to set those variables: framesize, repeat, etc, then call config_camera() which sets up the camera and sets up the queuing system, and then the magic statement "recording = 1" will start the make_avi() system which opens the files and signals the camera system to start taking pictures.

The recording will stop when the time runs out, and start new recordings until the "repeat" runs out and will then do nothing but wait for http/ftp commands.

To stop a recording or group of recordings with code, just use "recording = 0", and it will close the current avi file (after emptying the queue and writing the index), and it will also zero-out the "repeat" variable if you were recording a group.

The new_config variable just prevents the camera from being re-configured if not necessary. The "esp_camera_init" fails fairly regularly, so I use it sparingly.

// // startup defaults -- EDIT HERE // zzz

framesize = 10; // uxga repeat = 100; // 100 files xspeed = 30; // 30x playback speed gray = 0; // not gray quality = 10; // 10 on the 0..64 scale, or 10..50 subscale capture_interval = 1000; // 1000 ms or 1 second total_frames = 1800; // 1800 frames or 60 x 30 = 30 minutes xlength = total_frames * capture_interval / 1000;

new_config = 5; // 5 means we have not configured the camera // 1 setup as vga, 2 setup as uxga // 3 move from uxga -> vga // 4 move from vga -> uxga

newfile = 0; // no file is open // don't fiddle with this! recording = 0; // we are NOT recording

config_camera();

recording = 1; // we are recording