ESP32-CAM-Video-Recorder/README.md

225 wiersze
12 KiB
Markdown
Czysty Zwykły widok Historia

2019-08-03 05:09:17 +00:00
# ESP32-CAM-Video-Recorder
2019-09-17 19:31:03 +00:00
Video Recorder for ESP32-CAM with http server for config and ftp server to download video
2019-08-03 06:39:10 +00:00
2019-08-06 02:23:58 +00:00
TimeLapseAvi
ESP32-CAM Video Recorder
2019-09-17 19:31:03 +00:00
This program records an MJPEG AVI video on the SD Card of an ESP32-CAM.
2019-08-06 02:23:58 +00:00
by James Zahary July 20, 2019
jamzah.plc@gmail.com
https://github.com/jameszah/ESP32-CAM-Video-Recorder
2020-02-25 02:22:19 +00:00
2020-02-25 02:32:18 +00:00
jameszah/ESP32-CAM-Video-Recorder is licensed under the GNU General Public License v3.0
2020-02-25 00:28:04 +00:00
2020-07-02 00:53:29 +00:00
## Update Jun 30, 2020 Version 86 - some new features
<img src="./v86/v86.jpg">
# Software
- redo camera scheduler to reduce frame skips with slight delays between frames
- move more processing to separate priority tasks, and remove from idle loop()
- most tasks suspened waiting for events, rather than loopong checking for events, ... except ftp which still loops wating for ftp requests
- added a sd card snapshot jpg at beginning of every movie
- added a telegram.org message with opening picture and info about diskspace and rssi to follow camera activity on your computer or phone
- added deepsleep feature to wake on PIR, and then deepsleep after movie is recorded
- added touch sensor on pin12 to enable/disable the pir sensor
- added more careful setup of difficult pins 12, 13, and 4 - used for SD and re-used for PIR, Touch, and Blinding Disk-Active Light
- added brownout handler to close files on brownout, which didn't work, but at least I can deepsleep to prevent multiple brownout reboots. (Inside a brownout handler, you have only 300ms and you cannot access wifi, sd, or flash, ... so cannot close files, or send message.)
- re-used pin 4 Blinding Disk-Active Light to blink gently at beginning of movie, and at a Touch - ironically, also turns on during Brownout ;-)
- added several functions to enable / disable pir or bot using internet
- http://desklens.local/bot_enable
- http://desklens.local/bot_disable
- http://desklens.local/pir_enable
- http://desklens.local/pir_disable
- http://desklens.local/ ... look through viewfinder and see status
- http://desklens.local/stop
- http://desklens.local/start ... with existing or default parameters
- http://desklens.local/start?framesize=VGA&length=1800&interval=250&quality=10&repeat=100&speed=1&gray=0
- see below or settings.h
- moved many settings to a separate file "settings.h" so you edit that, rather than digging through the main file to set your wifi password, startup defaults, and enable/disable internet, pir, telegram, etc
- not super-elegant code ... still haven't written the avi writer into a nice library
- read comment on rtc_cntl.h below which may or may not be updated in the esp32 board library - links and info below
# Hardware
- to use PIR function, put an active high PIR or microwave on pin 12 with a 10k resistor (brown,black,orange) between pin 12 and PIR output to avoid antagonizing sd card
- to use Touch function, put a wire (with optional metal touch point) on pin 13 and touch it to enable/disable pir
- Blinding Disk-Active Light will give little blink during a touch, or when starting a recording
- red led on back with blink with every frame if you have that enabled in settings
Here is the "/" status page
<img src="./v86/v86-status.jpg">
And the /stop page to restart with new parameters
<img src="./v86/v86-stop.jpg">
2020-03-01 07:14:56 +00:00
## Update Feb 29, 2020 Sample Hardware for Microwave Camera
This is a bit of hardware to set up a camera recording to SD Card whenever something moves, as seen through a microwave device, and adds a led so you can see when the camera sees you!
2020-03-01 07:15:34 +00:00
<img src="./demo_fritz3.jpg">
2020-03-01 07:14:56 +00:00
<img src="./demo4.jpg">
<img src="./deom5.jpg">
2020-02-26 01:45:30 +00:00
## Update Feb 25, 2020 Sample Hardware for PIR Camera
This is a bit of hardware to set up a camera recording to SD Card whenever something moves.
2020-03-01 07:14:56 +00:00
<img src="./demo_fritz2.jpg">(my microUSB adapter is different from the one in the library)
2020-02-26 01:45:30 +00:00
<img src="./demo1.jpg">
<img src="./demo2.jpg">
<img src="./demo3.jpg">
2020-02-26 22:35:06 +00:00
## Update Feb 26, 2020 TimeLapseAvi60x.ino
2020-02-25 00:25:10 +00:00
2020-02-26 22:35:06 +00:00
New version # 60
2020-02-25 18:39:05 +00:00
- moved from 4 bit SD access to 1 bit, which frees up gpio pins 4, 12, and 13
2020-02-25 00:25:10 +00:00
- the Blinding Disk-Access Light is now OFF, without soldering or tape
2020-02-25 03:32:13 +00:00
- pin 12 can now be used for a PIR or switch - pull it high to start a 15 second video, continuing until 10 seconds after it goes low
2020-02-25 00:25:10 +00:00
- to use PIR or switch, the machine must not be recording, so edit "record_on_reboot" to 0, or use web to stop recording
2020-02-25 02:46:31 +00:00
- if you want no internet, just leave the fake ssid and password, and it will date your PIR recordings as 1970, but keep all your PIR clips timed and dated after 1970, which is better than just numbering them
2020-02-25 03:32:13 +00:00
- default startup is VGA, 10 fps, quailty 10, 30 minutes long, playback realtime, repeat 100 times, and it starts automatically after a reboot -- this is actually a little aggressive for my LEXAR 300x 32GB microSDHC UHS-I, which will usually keep up with 10 fps, but will sometimes start skipping
2020-02-26 22:47:02 +00:00
- BlinkWithWrite #define of 1 will blink the little red led with every frame, or #define 0 will just blink SOS if the camera or sd card are broken, or if you are skipping frames because sd cannot keep up
2020-02-26 22:35:06 +00:00
- also implemented dates and times in ftp which had been mysteriously missing. The "Date Modified" on Windows should now be the correct time the file was completed on the ESP32. The "Date Created" will be the time you ftp'ed it. And the time in the file name is the time the file was started recording on the ESP32.
- also note that the file names of the PIR files are all just "L15" (the original creation of the file), but the files themselves will be as long as the PIR had activity. I haven't updated the filename for the eventual length.
- you just need the 3 files from the /v60 folder
- I'll rewrite this intro with v60 instructions ... at some point
2020-02-25 02:46:31 +00:00
Also, someone did an instructables.com explanation and video about the Sep 15, 2019 version, which is not bad.
2020-02-26 09:23:38 +00:00
I am refered to as "The Team" :-)
2020-02-25 02:46:31 +00:00
https://www.instructables.com/id/Video-Capture-Using-the-ESP32-CAM-Board/
2020-02-25 03:02:04 +00:00
Other general advice about the ESP32-CAM.
- put a capacitor between the +5 and Ground to prevent the frequent "brownout" problems. I saw 220 microFarad recommended somewhere, and it works good.
2020-02-26 09:23:38 +00:00
- keep the antenna part of the chip - the part with the squiggly line - above and away from your circuit board or any wires. The internet speed will improve dramatically with just 1 or 2 mm of extra space.
2020-02-25 00:28:04 +00:00
2020-02-25 00:32:02 +00:00
## Update Feb 18, 2020
2020-02-18 20:44:41 +00:00
- Check out https://github.com/s60sc/ESP32-CAM_MJPEG2SD
It is a similar program, but makes a ".mjpeg" file rather than an ".avi" file.
2020-02-26 09:23:38 +00:00
It will also give you the live-stream through the camera to your
2020-02-18 20:44:41 +00:00
browser, it will play the videos for you through the browser, and
it will record based on a PIR or other sensor that grounds a pin.
And it solves the "Blinding Disk-Active Light" without any soldering or tape.
Reference by amirjak over in the "Issues" section.
I will be borrowing a few of these good ideas in days to come!
2020-02-25 00:28:04 +00:00
2020-02-25 00:32:02 +00:00
## Update Oct 15, 2019
2019-10-18 04:27:01 +00:00
- Make sure you are using esp32 board library 1.03 or better
- 1.02 has major wifi problems !!!
2020-02-25 00:28:04 +00:00
2020-02-25 00:32:02 +00:00
## Update Sep 15, 2019 TimeLapseAvi39x.ino
2020-02-25 02:29:11 +00:00
"work-in-progress" I'm publishing this as a few people have been asking or working on this.
2020-02-25 02:18:38 +00:00
- program now uses both cores with core 0 taking pictures and queueing them for a separate task on core 1 writing them to the avi file on the sd card
- the loop() task on core 1 now just handles the ftp system and http server
- dropped fixed ip and switch to mDNS with name "desklens", which can be typed into browser, and also used as wifi name on router
- small change to ftp to cooperate with WinSCP program
2020-02-25 02:25:22 +00:00
- fixed bug so Windows would calulcate the correct length (time length) of avi
2020-02-25 02:18:38 +00:00
- when queue of frames gets full, it skips every other frame to try to catch up
- camera is re-configued when changing from UXGA <> VGA to allow for more buffers with the smaller frames
2019-09-17 19:35:46 +00:00
You just need the 3 files in the /v23 folder for July version, which takes a picture and stores it
or the 3 files in the /v39 folder for the current which adds the queueing system to get better
frame rates, and keep recording if there is a small delay on file system.
2020-02-25 00:28:04 +00:00
2020-02-25 00:32:02 +00:00
## Original July 2019 Intro
2019-09-17 19:26:42 +00:00
2019-08-06 02:23:58 +00:00
Acknowlegements:
1. https://robotzero.one/time-lapse-esp32-cameras/
Timelapse programs for ESP32-CAM version that sends snapshots of screen.
2. https://github.com/nailbuster/esp8266FTPServer
ftp server (slightly modifed to get the directory function working)
3. https://github.com/ArduCAM/Arduino/tree/master/ArduCAM/examples/mini
ArduCAM Mini demo (C)2017 LeeWeb: http://www.ArduCAM.com
I copied the structure of the avi file, some calculations.
The is Arduino code, with standard setup for ESP32-CAM
- Board ESP32 Wrover Module
- Partition Scheme Huge APP (3MB No OTA)
This program records an AVI video on the SD Card of an ESP32-CAM.
It will record realtime video at limited framerates, or timelapses with the full resolution of the ESP32-CAM.
It is controlled by a web page it serves to stop and start recordings with many parameters, and look through the viewfinder.
You can control framesize (UXGA, VGA, ...), quality, length, and fps to record, and fps to playback later, etc.
There is also an ftp server to download the recordings to a PC.
Instructions:
The program uses a fixed IP of 192.168.1.222, so you can browse to it from your phone or computer.
http://192.168.1.222/ -- this gives you the status of the recording in progress and lets you look through the viewfinder
http://192.168.1.222/stop -- this stops the recording in progress and displays some sample commands to start new recordings
ftp://192.168.1.222/ -- gives you the ftp server
The ftp for esp32 seems to not be a full ftp. The Chrome Browser and the Windows command line ftp's did not work with this, but
the Raspbarian command line ftp works fine, and an old Windows ftp I have called CoffeeCup Free FTP also works, which is what I have been using.
You can download at about 450 KB/s -- which is better than having to retreive the SD chip if you camera is up in a tree!
2020-02-25 02:18:38 +00:00
http://192.168.1.222/start?framesize=VGA&length=1800&interval=250&quality=10&repeat=100&speed=1&gray=0
-- this is a sample to start a new recording
2019-08-06 03:04:15 +00:00
2019-08-06 04:03:27 +00:00
- framesize can be UXGA, SVGA, VGA, CIF (default VGA)
- length is length in seconds of the recording 0..3600 (default 1800)
- interval is the milli-seconds between frames (default 200)
2020-02-25 02:18:38 +00:00
- quality is a number 10..50 for the jpeg - smaller number is higher quality with bigger and more detailed jpeg (default 10)
2019-08-06 04:03:27 +00:00
- repeat is a number of who many of the same recordings should be made (default 100)
- speed is a factor to speed up realtime for a timelapse recording - 1 is realtime (default 1)
- gray is 1 for a grayscale video (default 0 - color)
2019-08-06 03:04:15 +00:00
These factors have to be within the limit of the SD chip to receive the data.
For example, using a LEXAR 300x 32GB microSDHC UHS-I, the following works for me:
- UXGA quality 10, 2 fps (or interval of 500ms)
- SVGA quality 10, 5 fps (200ms)
- VGA quality 10, 10 fps (100ms)
2019-08-06 04:12:55 +00:00
- CIF quality 10, 20 fps (50ms)
2019-08-06 03:04:15 +00:00
If you increase fps, you might have to reduce quality or framesize to keep it from dropping frames as it writes all the data to the SD chip.
2020-02-25 02:18:38 +00:00
Also, other SD chips will be faster or slower. I was using a SanDisk 16GB microSDHC "Up to 653X" - which was slower and more unpredictable than the LEXAR ???
2019-08-06 03:04:15 +00:00
Search for "zzz" to find places to modify the code for:
1. Your wifi name and password
2. Your preferred ip address (with default gateway, etc)
3. Your Timezone for use in filenames
4. Defaults for framesize, quality, ... and if the recording should start on reboot of the ESP32 without receiving a command
2019-08-06 02:23:58 +00:00
2019-08-06 04:03:27 +00:00
Sample videos produced by the program in the /sample-output folder -- it is not GoPro quality, but then GoPro's don't cost $10.
2020-02-25 02:18:38 +00:00
While not necessay, following is how I dealt with the "Flash" led on the front of the ESP32-CAM chip.
2019-08-03 06:52:34 +00:00
2019-08-03 06:45:58 +00:00
Picture below shows my solution to the "Flash" led, aka "the Blinding Disk-Active light". The led turns on whenever you are are writing data to the SD chip, which is normally after you have taken the picture, so you don't need the flash on any more!
2019-08-03 06:44:20 +00:00
Quick de-solder of the collector on the top of the J3Y transistor just above the led, then put in some tape to keep it clear -- you can solder it back later if you want to use it.
2019-08-03 06:39:10 +00:00
<img src="./de-solder.png">
2019-08-03 23:23:09 +00:00
2019-08-05 20:44:17 +00:00
<img src="./de-solder3.png">