Record avi video on ESP32-CAM and send to Telegram on event or request
Go to file
jameszah e873c1b99c
make tzchar longer on line 994
2021-10-31 10:37:26 -06:00
ESP32-CAM-Video-Telegram_8.8x.ino make tzchar longer on line 994 2021-10-31 10:37:26 -06:00
LICENSE Initial commit 2021-06-09 20:04:33 -06:00
README.md Update README.md 2021-06-12 12:59:17 -06:00
UniversalTelegramBot.cpp ver 8.8 Jun 10, 2021 2021-06-10 19:50:20 -06:00
UniversalTelegramBot.h ver 8.8 Jun 10, 2021 2021-06-10 19:50:20 -06:00
magpie.jpg Add files via upload 2021-06-10 16:41:46 -06:00
magpie1.jpg Add files via upload 2021-06-10 16:41:46 -06:00
telegram.jpg Add files via upload 2021-06-10 16:41:46 -06:00

README.md

ESP32-CAM-Video-Telegram

Record avi video on ESP32-CAM and send to Telegram on event or request

Description

This program runs on a simple ESP32-CAM module without a SD card installed, and will respond to Telegram requests to take a photo or video, and then send it to the Telegram server to arrive at your phone or computer. If you set up an active-high PIR or radar sesnsor to pull up Pin 13, then it will take a photo and a video of the event that set off the PIR, and then a video afterwards. The video can be "fast" at 25 frames-per-second, "med" at 8 fps, or "slow" at 2 fps. The video is recorded in the psram of the ESP32-CAM module, so there is only about 3MB of space available, which means about 60 bright outdoor frames, or 150 dull bland frames. So the videos will be about 3 seconds, 10 seconds, and 40 seconds long. As well, it is set to play the fast video at half speed, the medium video at realtime, and the slow video at 5x speed, so your 40 seconds video will play in timelapse over 10 seconds or so.

You could adjust the quality parameters of the framesize to get more frames for longer videos. It is currently set up for VGA (640x480) and quality 10 (good, not great), so you could switch to QVGA (320x240) and quality 20 to get many more frames with the 3MB buffer. The ov2640 camera and drivers also double in speed below CIF (400x296) size. (I think that still works?)

Demo

As seen on Telegram screen:

Click below to see DoorCam....avi as seen on Youtube - the picture here is the first frame of the avi, which is one frame after the jpeg sent to Telegram or about 40ms. It does not go to Youtube automatically - I just did that as I cannot play a video from github site. But you can download it below. Telegram only handles mp4 files inline, so the avi just appears as a file.

Click to see on Youtube

The file as served by Telegram:

https://github.com/jameszah/ESP32-CAM-Video-Recorder-samples/blob/master/ESP32-Cam-Telegram/DoorCam%202021-06-03%2014.47.52.avi

The file uploaded to Youtube - now converted to Youtube's formats:
https://youtu.be/x4JaLOefIWA

Click to see the 25 fps in slow motion.

Click to see on Youtube

Click to see the 2 fps in 5x timeslapse motion. This is very dull light, meaning the frames are small and you get over 1 minute at 2 fps played over 15 seconds, and even then it hit the 150 frames limit, rather than the 3MB limit.

Click to see on Youtube

Controls

If you put in your correct Telegram chat_id, you will get a message when the ESP32-CAM boots, and then the /start command will produce the following.
You can ask for a photo or a clip (photo plus avi), or reconfigure the ESP32 for different clip lengths, and disable the PIR, or disable the "avi", which means it will just send the photo and skip the avi.

The 3MB clip can take a minute to send to the Telegram server, so you may want to shut if off at times. I'm not sure how many 3MB avi's Telegram will store for you, or if they get annoyed if you send too many. They also pile up on my Android phone, so you need to empty your Telegram history from time to time.

It defaults to PIR enabled, and avi enabled amd a "fast" 25fps 3 second video.

Compile Time Parameters

char ssid[] = "yourssid";         
char password[] = "yourssidpass"; 
String TIMEZONE = "GMT0BST,M3.5.0/01,M10.5.0/02";  
String chat_id = "1234567890";
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 

// see here for information about getting free telegram credentials
// https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot
// https://randomnerdtutorials.com/telegram-esp32-motion-detection-arduino/
// find your timezone here 
// https://sites.google.com/a/usapiens.com/opnode/time-zones  

Hardware

Hardware looks similar to the photos, samples over here.
Just remember it is gpio 13 with a big resistor (10 Kohm), active high PIR, and it makes sense to put a big capacitor between power and ground to cover currennt surges from the WiFi.

https://github.com/jameszah/ESP32-CAM-Video-Recorder