Giter Site home page Giter Site logo

jameszah / esp32-cam-video-recorder Goto Github PK

View Code? Open in Web Editor NEW
440.0 26.0 100.0 185.21 MB

Video Recorder for ESP32-CAM with http server for config and ftp (or http) server to download video

License: GNU General Public License v3.0

C++ 95.88% C 4.12%
esp32 esp32-cam avi video-recorder ov2640 esp32-cam-video-recorder mjpeg ftp-server pir

esp32-cam-video-recorder's Introduction

ESP32-CAM-Video-Recorder

Video Recorder for ESP32-CAM with http server for config and ftp server to download video

TimeLapseAvi

ESP32-CAM Video Recorder

This program records an MJPEG AVI video on the SD Card of an ESP32-CAM.

by James Zahary July 20, 2019 [email protected]

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

jameszah/ESP32-CAM-Video-Recorder is licensed under the GNU General Public License v3.0

vA1 for arduino-esp32 2.0.2
v99 for arduino-esp32 1.0.6
v98 for arduino-esp32 1.0.4

Update Jan 12, 2022 - esp32-arduino 2.0.2 and replace ftp with http file transfer

Version A1 - Jan 1, 2022

The esp32-arduino 2.0.2 contains some nicer camera code that clears away little glitches that used to pop up.
It is very clean now!

You can hardcode your ssid and password into settings.h, or put in a 1 character long ssid, and it will use WiFiManager to set your ssid and password. If you want Telegram bot to work, you still have to hardcode them into settings.h

More commentary coming ... and refinements ... test it before you use it.

Also the newer quicker version (with fewer features) over at https://github.com/jameszah/ESP32-CAM-Video-Recorder-junior

You can download the videos to your computer or phone with just a click on the file from your browser -- no need for an ftp program anymore!

If you have the telegram bot turned on, it will send your telegram app the first frame of a new recording, and give you a link to the previous recording for you to download to your phone or computer with one click.

Jan 17, 2022 - small update to fix the file delete when disk full required by 2.0.2


old stuff below - might contain details not applicable to current version


Note line 1413 -- this current version uses the WiFiManager for all WiFi setup. Change this line if you want to use the previous version of hardcoded ssid and password.

Update Sep 1, 2021 - small update for arduino-esp32 1.0.6

Minimal update for arduino-esp32 1.0.6.

The framesizes numbers changed which I had used on the http url command, so those were updated.
Add the new frame size HD (1280x720).
Some updates for the new SSL libraries to keep the telegram interface working.
You need all the files in the v99 folder. And Arduino esp32 board library set to 1.0.6.
You can still use the previous version with the esp32 board library set to 1.0.4.

Lightly tested!

More frequent updates with better code at these spin-offs of this original project.

https://github.com/jameszah/ESP32-CAM-Video-Recorder-junior
This simple fast recording and streaming, with http just for information - no controls or ftp.

https://github.com/jameszah/ESP32-CAM-Video-Telegram
This records and sends a short video to telegram on request or PIR event, using the telegram interface.

Update Jun 10, 2021 - new program to check out

It records a video and sends it to your Telegram account - no SD card! Now I just need to do some updates on this one!

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

Update Mar 17, 2021 - arduino-esp32 ver 1.05

It would be best to use arduino-esp32 version 1.04 until I scan through this for update problems.
1.05 was released in late Feb 2021, has has some new framesizes, aspect rations, and some changes in the WiFi, that need some code changes.

image

Update Jan 06, 2021 - Version 98-WiFiMan

Just the same as Verion 98, but you can configure the ssid and password using WiFiManager.
Use the normal WiFiManager procedure to set up ssid with 192.168.4.1 etc https://github.com/tzapu/WiFiManager The only difference is that you have to reboot the esp32 after you have set the ssid/pass for it to work correctly. Read more about it here tzapu/WiFiManager#1184

And you must use the latest WiFiManager code which supports the ESP32 - currently 2.0.3-alpha which can be installed from Arduino IDE - Manage Libraries. The WiFiManager could be enhanced to set parameters that cannot be set from hhtp, such as Telegram name and password, but haven't done that yet.

https://github.com/jameszah/ESP32-CAM-Video-Recorder/tree/master/v98-WiFiMan

Update Sep 29, 2020 - Version 98

Added a feature to automatically delete your oldest day of videos when the SD reaches 90% full.

There are also some compile directives in the settings.h file to cut out entire sections of code like the ftp or telegram, if you need resouces to add your own stuff.

Update Sep 13, 2020

Check out a much simpler, somewhat faster version ESP32-CAM-Video_Recorder-junior.

It gets rid of wifi, http, time, ftp, telegram, pir, touch, .... and just records very fast -- pretty much at the full speed of the camera -- with a decent SD card and reasonable quality parameters.

The latest version of junior v07 adds back the streaming video, and series of photos over wifi, and will record at 6 fps UXGA and 24 fps SVGA, but otherwise remains quite uncomplicated.

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

Update Aug 29, 2020 Version 94 - live stream and filter bad jpegs

A couple new things.

I added some code to filter out bad jpegs. This happens when you have high quality jpeg settings, and then take a movie in bright light, and some of the jpegs exceed the memory allocated, and you get a partial jpeg, which will screw up the index, and break an entire avi. So there is now code to find those bad jpegs, and get a new frame that is good. Read more about this here if interested. espressif/esp32-camera#162

This means it is safe to increase the jpeg quality to 7 (maybe 6?) from the standard setting of 10, or 12 in bright sun. Lower number is higher quality. Higher quality will mean more bytes, bigger files, and slower to write. It is debatable if you want very high quality jpegs if they are flashing along at 24 frames per second.

Another new feature is a streaming video. There is the single frame on the main status screen so you code see what your camera sees, but the streaming has been much requested to get a better look through the viewfinder, and maybe save the stream.

You set a parameter in settings.h of milli-seconds between updates, and then click on the /stream link on the main web page and it will stream to a new browser window. Hit "back" to get back to the main page.

To save the video coming to the browser, do the following -- I tried to figure this out before but could not find it on google.

  1. Click on the /stream on the web page, and you will see the moving picture.
  2. Right-click and select "save image as ...", type a name, and it will start saving the series of jpegs to a file.
  3. You have to stop the save, which as far as I can figure out, you have to select cancel from the menu of the ever increasing file. But that will delete the file that you have been saving. So the kludge is to "show in folder" to find the file, then copy the file, then do the cancel. Then you have to rename that file to x.mjpeg, and then you can play it. Most programs that play .avi files will not play the .mjpeg, but some will. See VLC below. Very inelegant.

Another method is to use the VLC media player program.

  1. Media - Open Network Stream - paste in the url such as http://192.168.1.90/stream
  2. Then in the Play menu, switch it to Convert, click on "Dump Raw Input" and type filename ending in .mjpeg, and click Start. When you are down saving, click the square stop button. You will get a .mjpeg file which can be played in VLC and some other video or picture players. An mjpeg does not understand time, so it will play the picture as quick as it can, and you have have to enter new information about the time between frames to get it to play as you want.

VLC seems to have controls there to convert the file to various formats like h264, wmv, etc. but I could not get that to work.

If anyone has better ways to capture the live stream, or capture and covert it, please let us know in the comments.

I have not really studied how the streaming interacts with the recording. But 3 fps streaming seems to work fine with 8 fps svga recording. More work to be done there. I reduced the http task priorty to below the picture-taking and avi-writing tasks, so the the streaming should slow down before the recording. It seems the esp32 http server can only handle one client at a time, so you cannot stream to one browser and check the status on another browser.

Another small feature is that you can now tell the recorder to /stop, and then /start with no parameters, and it will restart according to the original start parameters. Not only the framesize and interval, but if you set it to record 100 videos, and it has 5 left, after a /stop and /start it will restart at 100 videos.

Also if you have some parameters in EPROM, and your are doing a new compile with changes and you do not want to use those EPROM parameters, there is a setting called MagicNumber in the settings.h. Just change the MagicNumber, and the program will skip the EPROM settings and write your new settings from settings.h

I changed to default startup settings to VGA 10 frames per second, play at realtime, with no PIR or BOT.

Update Jul 15, 2020 Version 89 - more new stuff

  • added some code to save the configuration in eprom, so your device will always reboot to the state set in your most recent /start command. The previous system just had a hardcoded configuration, and let you /stop and /start in a new configuration, but after a series of squirrel attacks, I moved to the eprom solution. It always starts where it was, although a movie in progress during the squirrel attack will be lost. You can enable or disable the telegram bot or PIR sensor with a web-page click, and that too will be added to the eprom, so it reboots with or without bot updates or PIR control. On reboot, it will check your eprom to see if there are parameters, and if so it will use them, or else use the hardcoded parameters from settings.h, and then write those paramters into eprom for next boot. Change the eprom parameters with the /start command below.

  • changed the movie start procedure a little. It now takes a snapshot at beginning of movie, saves it as a .jpg, and if Telegram bot is enabled sends that same picture to your telegram so you can monitor the activity on your phone, or use that jpg if you want. It does take several seconds to send the picture to telegram. And only after that does it start recording the movie. I attempted to do the telegram send after the movie started recording, but the telegram uses SSL security which needs 50k or more of heap, which would sometimes leave too little heap to work the SD card. Also the reboot from deepsleep takes a couple seconds, then starting internet takes a couple seconds, then telegram bot takes a couple seconds, and then the movie starts. So if you want fast-start, then don't use deepsleep, turn off internet, and obviously turn off telegram.

  • changed reprogramming the camera a little. It used to re-set frame-size, quality with every movie, but now it is just when you make changes and at reboot.

  • I have switched to quality = 12 which is better for sunny days, and does noticably increase frame-rate. I can usually get SVGA working at 10 frames per second, which is decent realtime video.

The serial debug monitor shows you your ip address, and the web page uses the ip, rather than hoping that you can resolve mDNS everytime.

You just need the files from the /v89 folder. Edit the settings.h file for your wifi and startup configuration.

Update Jun 30, 2020 Version 86 - some new features

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 suspend waiting for events, rather than looping 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

  • 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

  • This includes a v1.2 (slight mods) of https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot for the Telegram stuff, plus the ftp and ArduCam mentioned below (major rewrite on ArduCam)

  • You just need the files from the /v86 folder. Edit the settings.h file for your wifi and starup configuration.

Hardware

  • to use PIR function, put an active high PIR or microwave on pin 13 with a 10k resistor (brown,black,orange) between pin 13 and PIR output to avoid antagonizing sd card
  • to use Touch function, put a wire (with optional metal touch point) on pin 12 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

And the /stop page to restart with new parameters

And what it looks like on your phone Telegram App

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!

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.

(my microUSB adapter is different from the one in the library)

Update Feb 26, 2020 TimeLapseAvi60x.ino

New version # 60

  • moved from 4 bit SD access to 1 bit, which frees up gpio pins 4, 12, and 13
  • the Blinding Disk-Access Light is now OFF, without soldering or tape
  • 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
  • to use PIR or switch, the machine must not be recording, so edit "record_on_reboot" to 0, or use web to stop recording
  • 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
  • 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
  • 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
  • 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

Also, someone did an instructables.com explanation and video about the Sep 15, 2019 version, which is not bad.
I am refered to as "The Team" :-)

https://www.instructables.com/id/Video-Capture-Using-the-ESP32-CAM-Board/

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.
  • 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.

Update Feb 18, 2020

It is a similar program, but makes a ".mjpeg" file rather than an ".avi" file.

It will also give you the live-stream through the camera to your 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!

Update Oct 15, 2019

  • Make sure you are using esp32 board library 1.03 or better
  • 1.02 has major wifi problems !!!

Update Sep 15, 2019 TimeLapseAvi39x.ino

"work-in-progress" I'm publishing this as a few people have been asking or working on this.

  • 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

  • fixed bug so Windows would calulcate the correct length (time length) of avi

  • 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

    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.

Original July 2019 Intro

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!

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

  • 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)
  • quality is a number 10..50 for the jpeg - smaller number is higher quality with bigger and more detailed jpeg (default 10)
  • 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)

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)
  • CIF quality 10, 20 fps (50ms)

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.

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 ???

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

Sample videos produced by the program in the /sample-output folder -- it is not GoPro quality, but then GoPro's don't cost $10.

While not necessay, following is how I dealt with the "Flash" led on the front of the ESP32-CAM chip.

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!

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.

esp32-cam-video-recorder's People

Contributors

jameszah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp32-cam-video-recorder's Issues

why do_fb() should run 5 times?

is it necessary?and would you mind telling me how to change camera mode (turn rgb to grayscale and change framesize)?i had read your code but i still have some question.

yours,
Atom

sd problem

Hi your project looks grate and it totaly fit my needs - i'm planning to build videotrap for birds feeder. anyway unfotunately after compiling v60 i'm getting sd error "can't" mount vfat. I use 8gb hc sd - it works with other esp32 cam projects. I would be gratefull for any advice.

How to do a forced-recompile (again)

In working with V94, I have been successful in changing the settings.h file back and forth many times, since I I'm leaving the WiFi disabled due to the distances I am flying. This has worked for the last few days... Now, I am stuck in the UXGA mode, while the settings.h has been changes to SVGA... It is like the compiler is again using cached older .o files or the like, and not updating with the new info. I believe what I want to do is a "forced Recompile"... I have been trying the ideas put forth in the closed ticket V94 compile problems(now closed) , including temporarily changing the board info (nothing), putting the project in a new portable folder, and changing the preferences to set the project up there( nothing). I have set the entire structure up as portable, as recommended, and using the arduino.exe located in the location C:\ArduinoPortable\arduino-1.8.13-esp32, as this has worked before.

Any Ideas how to finally get past this problem?
Thansk

Can´t Upload

At first nice work. Ive seen the result in a youtube-video.
Now to my problem:
I connectet the ESP-32 Camera Module properly via an Arduino to the Computer. Then I selectet the option as said in the Script:

  • Board Settings:
  • Board: "ESP32 Wrover Module"
  • Upload Speed: "921600"
  • Flash Frequency: "80MHz"
  • Flash Mode: "QIO"
  • Partition Scheme: "Hue APP (3MB No OTA/1MB SPIFFS)"
  • Core Debug Level: "None"
  • COM Port: Depends On Your System

Now when I try to upload the Sketch the following error shows up:
A fatal error occurred: Timed out waiting for packet header
`
esptool.py v2.6
Serial port COM4
Connecting........_____.
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: _________________
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...

A fatal error occurred: Timed out waiting for packet header
A fatal error occurred: Timed out waiting for packet header

`
The sample Sketch worked.
Or is there a instruction to upload it properly?

Maybe you have a solution.
Thank you!

ESP32 Wrover Module error?

The is Arduino code, with standard setup for ESP32-CAM
- Board ESP32 Wrover Module
- Partition Scheme Huge APP (3MB No OTA)

arduino 1.8.13
espressif systems 1.04
v98x-WiFiMan

Error compiling for development board esp32 wrover module

Why not?

TimeZone not changing

When setting timezone to: #define TIMEZONE "GMT+2" the time is set for the wrong timezone.

what would the correct TZ string be for South Africa ? GMT+2, no DST

I can't download anything from ftp server

Hi! I tried to record something, but when I want to download the record from ftp, I can't. The response is "This site can't be reached. Might be temporarily down or it may have moved permanently to a new web adress. To acces the ftp server I use Chrome. It is necesary to use a dedicated app like FileZila? Thank you for your answer.

Move samples to seperate storage

I cannot even clone the repo on my slow internet connection, its crazy big! Pointless to have samples as part of the code repo. Put it somewhere else (google drive, dropbox, github storage, etc) and link to it instead

question for the offline recorder(using only sd card)

hello there..

nowadays, I'm planning to make a offline recorder (using only sd card) for my own project..

Since the codes you wrote are hard for me to understand that I'm not a major programmer..

Can you get me some tips for removing wifi codes and using esp32 camera logging (log to sdcard) ?

Thanks for your awesome library!

Password protected webpage

Hi, I love your work! Can you implement a login form in the main webpage like the one in the ftp section please?
Thanks

Awakening from sleep

Hi! I would like to implement a method to wake up the ESP 32 Cam module by touching a wire.
I don't have an infrared sensor, I just have ESP 32 Cam and an Arduino Uno. And I wondering if it is possible to wake up the device by using one of the free pin from the Esp 32 Cam.
Thank you so much for your answer!

can i shoot photos every 5 seconds without making video recording ??

I need to take pictures every 5 seconds to make a timelapse ... but I saw that the code makes the recording of videos. Can you help me with this ???

i need the tcp functions and the telegram bot still working

remembering that i only need the photos every 5 seconds i need to disable video recording so as not to overfill my sd card

can i also schedule a start and end time for shots ??

My idea is to do daytime lapse so i need the photos to start shooting at 6 am and finish at 6 pm

can i schedule the time ??

AVI file has wrong aspect ratio

Hello,
When I try to playback the recorded video on VLC, the aspect ratio is wrong. The video has a vertical format as if it was filmed on an iPhone.
On quicktime, the video is all black. What player have you tested successfully?
Thanks

Brownout detection capacitor selection

Just wanted to ask about the 220uF capacitor selection to prevent brownout detection. I am unfortunately running out of 220uF caps but still have many 100uF or 470uF caps. Is there a reason for the 220uF capacitor or did you find out it works well to prevent brownout by trail and error?

Just wanted to say this project looks amazing! Very excited to try this project out without brownout detection restarts😁

How exacly the code records avi?

I'm trying to implement this for projects with esp-idf, junior.2x does the job but it's a little bit spaghetti. What exactly is the code doing?(Edit : btw thanks so much, your project saved me a lot of time) (I will publish after I finish, ofc)

OTA does not work

Due to the fact that IO03 ist used for TX of the USB interface and PIR-output I tried to update the firmware via OTA, but there is no network connection shown in the Arduino IDE. The web-interface itself works properly.
Is there a workaround?
What to do?

Not and issue ... but great job and suggetions

Thanks for publishing this code.
That's what I am looking for, however adding an external sensor to trigger the camera is cumbersome, typically when trying to integrate all the hardware in an existing fake camera box.
Did you look at:
https://eloquentarduino.github.io/2020/01/motion-detection-with-esp32-cam-only-arduino-version/
This is what I am trying to implement concurrent to your code to trigger the SD data store. I will let you know if I succeed....;-)
I am also looking to add a real-time connection from the WEB interface, and automate the FTP transfer to a server running an avi viewer, may be triggered by a published MQTT message to a broker.
Adding basic security to access the Camera could be also nice .
So plenty of ideas, anyway thanks already for your development

Robert

Clean SD card automatically?

Hi, does this project delete the older files of the SD card when there is almost no space available?
Also, How much time did you manage to record at what resolution and what size of SD card?
I'm planning on doing a surveillance camera with the Esp32-cam

Need assistance with settings.h

Hi, and thanks for keeping this project active. I'm unable to set the framesize , even though I modify settings.h as shown, it reverts to the value of 6, unless I use the WiFI connection to use your pre-assigned menus... then the framesize changes.
Any ideas? I'm pretty sure the sketch is using the settings.h located in the libraries folder (as it compiles) could there be a copy in your 1.04 library?
Sam
nt framesize = 7; // 10 UXGA, 7 SVGA, 6 VGA, 5 CIF
int repeat_config = 10; // repaeat same movie this many times
int xspeed = 1;

No download possible with Android FTP client

I like to work with V89. But I can not download the videos with Android FTP client. It seems , Login is ok, but LIST or LISTchild can not deal with the file name or file date....
FileZilla with Win10 works properly.
Any idea is appreciated

Settings.h changes ignored

Hi. Thank you so much for your program.
using V98. My problem is that changes to settings.h seem to be ignored. I want the ESP32-CAM to boot in PIR Sensor mode. But it always boots up starting to record and HTTP server enabled.

I want it to start in a "stopped mode" so that it is only activated by PIR. Right now what I have to do is manually use the HTTP page to stop the recording. Only then it works with my PIR sensor. How do I automate this? Don't record after booting, stop and wait for PIR Sensor on GPIO 13? thanks

I printout the DeepSleepPir value in loop():

void loop()
{
  if (first) {
    Serial.print("the loop, core ");  Serial.print(xPortGetCoreID());
    Serial.print(", priority = "); Serial.println(uxTaskPriorityGet(NULL));
    //vTaskPrioritySet( NULL, 2 );
    //print_ram();
    first = 0;
  }

#ifdef include_pir_and_touch
  Serial.print(" **** DeepSleepPir="); Serial.println(DeepSleepPir);

  if (DeepSleepPir) {
    if (recording == 0 && PIRenabled == 1) {

Although in settings.h DeepSleepPir = 1; , in the code it is always 0.
**** DeepSleepPir=0
**** DeepSleepPir=0
...

And we can see in boot messages that settings.h config is not reflected in TimeLapseAvi98x.ino. DeepSleepPir is 0, but should be 1.

-------------------------------------
ESP-CAM Video Recorder v98
 http://desklens.local - to access `the` camera
-------------------------------------
Boot number: 1
Wakeup was not caused by deep sleep: 0
Get took 1
Good settings in the EPROM 
Internet_Enabled 1
DeepSleepPir 0
record_on_reboot 1
PIRpin 13
PIRenabled 1
framesize 7
repeat_config 100
xspeed 1
gray 0
quality 10

my settings.h:

static const char devname[] = "desklens";  // name of your camera for mDNS, Router, and filenames

#define include_telegram
#define include_pir_and_touch
#define include_ftp
#define include_streaming
#define get_rid_of_touch

int delete_old_files = 1; 
#define TIMEZONE "PST8PDT,M3.2.0,M11.1.0"             // your timezone  -  this is Pacific
#define BlinkWithWrite 1

// EDIT ssid and password
const char* ssid = "----";
const char* password = "----";

// reboot startup parameters here
int Internet_Enabled = 0;      // set to 0 to shut off all internet activities - wifi, time, http, ftp, telegram
int DeepSleepPir  = 1;           // set to 1 to deepsleep between pir videos
int record_on_reboot = 0;     // set to 1 to record, or 0 to NOT record on reboot
int PIRpin = 13;                   // for active high pir or microwave etc
int PIRenabled = 1;                // 1 is PIR is enable on reboot, will only work if you are not recording

int MagicNumber = 011;         
int stream_interval = 333;

 // SVGA
int  framesize = 7;                //  10 UXGA, 7 SVGA, 6 VGA, 5 CIF
int  repeat_config = 900;      
int  xspeed = 2;                    
int  gray = 0;                  
int  quality = 12;          
int  capture_interval = 200;     
volatile int  total_frames_config = 3600; 

SD_CARD Limitations

Hi All .. new to this forum and the ESP32.. Been making good progress looking at SD-CARDS, and indeed, , there can be a 4:1 difference in the achievable speeds with different grades and vendors. The best so far has been the SanDisk Ultra, rated 98MB/s, MicroSDHC UHS1... It labelled the same as the grey white version, which is 60% slower.(the fast one has the in the grey/red package). Looks like the best I'm able to do is on a 800x600 video, 116527 bytes/frame in 264ms, so I'm averaging .35-.5 MB/s... This seems terribly below what the cards are spec'd. Anyone know if a way to speed things up?
20200826_180726_002

How to get deep sleep working?

I'm trying to wake up the esp32 with a pir, but it keeps waking up, even with no connection on the pin.

The same pir is working with another sketch, so i assume it has something to do with the recorder code?
I'm using this in the loop function:

if (recording == 0) {
    Serial.println("Entering deep sleep mode");
    Serial.flush(); 
    esp_sleep_enable_ext0_wakeup(PIR_PIN, 1);   //wake up when pin 12 goes HIGH
    esp_deep_sleep_start();  
  }

Compile error V94

Hi;;; Had V89 compiling perfectly, so setup a Sketch folder for V94 in the same directory as V89...:
Am getting the following compile error ,as it seems a library issue:
Thanks:

TimeLapseAvi94x:881:33: error: 'httpd_req_t' was not declared in this scope
static esp_err_t stream_handler(httpd_req_t *req) {
^
TimeLapseAvi94x:881:46: error: 'req' was not declared in this scope
static esp_err_t stream_handler(httpd_req_t *req) {
^
image
image

Delete fork Task

Hello Sir,

Is there any provision if SD card full with memory.. so ESP-CAM start check old video and deleting ..
it will keep minimum current week/month data..as per configuration.

UniversalTelegramBot.cpp:132:37: error: 'measureJson' was not declared in this scope

Hi Jamesah,
sorry for my poor english, i don't speak it very well.
First, thanks for your great job!!!

I'm facing an issue, when I test your code, Arduino IDE respond this message:

_sketch\UniversalTelegramBot.cpp: In member function 'String UniversalTelegramBot::sendPostToTelegram(String, ArduinoJson::JsonObject)':
UniversalTelegramBot.cpp:132:37: error: 'measureJson' was not declared in this scope
int length = measureJson(payload);

I don't understand the problem, can you help me?

Regards,

Missing file or directory

Dear Sir/Madam,

I am currently working on v98. However, it is unable to compile due to missing header files such as those in the image below (with the exception of Wifi.h).

image

May I check whether I am supposed to download them from another repository, etc.?

Thank you for your kind assistance in advance.

Best regards,
Justin

PIR sensor documentation clarification

When I first added a pir sensor to the camera I left the pir sensor to its default settings that it came with from the mail. A couple questions that came up while reviewing my pir sensor settings as I noticed my video files are shorter than expected which could be due to my pir settings I discovered. Anyhow a picture and a sentence or two on the main page would be valuable for others replicating this project:

Most of the pir sensors have 3 adjustable settings. Sensitivity adjustment potentiometer, Triggered time adjustment potentiometer and Retriggerable and non-retriggerable jumper switch or solder pads depending on the variation you have.

  1. Sensitivity is the amount of heat sensed that can trigger the sensor. Is this image is anything to go by clockwise rotation would make it more sensitive and counter clockwise less sensitive:
    image

  2. Trigger time adjustment or adjust delay time as they name it in the picture above is the amount of time the signal stays high when the sensor is triggered. Clockwise rotation would make the output pin of the sensor stay high for a longer time when the sensor is triggered and counter clockwise rotation would make the high output last shorter after triggering.

  3. The retriggerable and non-retriggerable jumper switch or solder pads, when set to the “H” setting it means that it is retriggerable and that if the sensor is triggered and after a couple seconds when the output is still high it would restart the trigger time adjustment so that the high output signal is maintained for a longer time. If the sensor would be retriggered constantly it would never go low theoretically. If the jumper is set to the “L” setting which is non-retriggerable. It means that when the sensor is triggered and the output goes high the sensor can not be retriggered to for the duration for the time delay even when a heat source is moving I front of the sensor and the output fill go low after the time delay set with the potentiometer will run out and the sensor output will go low before it goes high again if the heat source is still moving in front of the sensor.

In my case I was experiencing that most videos on my SD card were shorter than expected and that some videos were longer. This could be due to two things that I am currently troubleshooting. First it could be due to that my 64Gb SD card that I formatted to FAT32 is not working well. I switched it to another 32Gb SD card now. While changing the SD card I thought it might be also due to my PIR as it was set to the “L” setting with the jumper. So set to non-retriggerable. So this means that if the motion is detected for a longer time than my
trigger time adjustment was set that the output of the sensor would go high, low, high, low. Etc. Is the camera starting a new recording every time it goes high after being low? This could have been why some of my videos on the SD card were shorter than expected.

I hope you will find the information above useful and saves you at least the time to type it out yourself on the information/main page of this awesome GitHub project!

How to set default recording settings? and override oldest file when SD is full?

First off, great project!! I have been using it for some time already and it is absolutely amazing! I am always eager to immediately try out new versions you post :-)

How do I set the default recording settings? I mean the initial settings after programming the board? Up to now I have been going into the web interface to change the settings to fit my needs.

And would it be possible to implement a feature so that the ESP would override and replace the oldest recording if the SD card is full?

Library time.h

Bonjour
j'ai apprécié votre code
Mais je n'arrive pas à obtenir la date pour l'enregistrement des photos et des videos.
Je pense que cela vient du fichier time.h
J'ai mis à jour avec Time-1.6.0.zip
https://github.com/PaulStoffregen/Time
ecran_serveur
Ce fichier est remplacé par Timelib.h
Quand j'utilise Timelib.h j'ai de nombreuses erreur de compilation.

Merci de me conseiller pour solutionner mon problème.

sending to Telegram not working...

Tried v98 and also v98-wifiman but i get an error when the esp32 tries to send a picture.

Heres the serial output:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:10944
load:0x40080400,len:6388
entry 0x400806b4


---
setup, core 1, priority = 1
                                    
-------------------------------------
ESP-CAM Video Recorder v98x-WiFiMan
 http://espcam.local - to access the camera
-------------------------------------
Boot number: 1
Wakeup was not caused by deep sleep: 0
Get took 2
Good settings in the EPROM 
Internet_Enabled 1
DeepSleepPir 0
record_on_reboot 0
PIRpin 13
PIRenabled 1
framesize 7
repeat_config 100
xspeed 1
gray 0
quality 12
capture_interval 100
total_frames_config 18000
xlength 15
EnableBOT 1
Starting wifi ...
 Disable brownout

BrownOut Regsiter was (in hex) 40028000
*WM: [1] AutoConnect 
*WM: [2] ESP32 event handler enabled 
*WM: [2] Connecting as wifi client... 
*WM: [3] STA static IP:
*WM: [2] setSTAConfig static ip not set, skipping 
*WM: [1] Connecting to SAVED AP: ****
*WM: [3] Using Password: ******
*WM: [3] WiFi station enable 
*WM: [2] 20000 ms connectTimeout set
*WM: [2] 20000 ms timeout, waiting for connect...
*WM: [2] . 
*WM: [2] . 
*WM: [2] . 
*WM: [2] Connection result: WL_CONNECTED
*WM: [3] lastconxresult: WL_CONNECTED
*WM: [1] AutoConnect: SUCCESS 
*WM: [1] STA IP Address: 192.168.1.122
Succesful Connection using WiFiManager
*WM: [3] unloading 
mDNS responder started 'espcam'
Local time: Thu Mar 11 21:04:07 2021

 Enable brownout
Starting sd card ...
SD card mount successfully!
Name: SU01G
Type: SDSC
Speed: 20 MHz
Size: 968MB
SD_MMC Begin: 1
Starting server ...
http task prio: 1
Camera http started
Starting ftp ...
Total space: 967MB
Used space: 790MB
Starting tasks ...
camera, core 1, priority = 2
aviwriter, core 1, priority = 3
ftp, core 0, priority = 4
Starting camera ...
PIRpin = 1, 1, 1, 1, 1,  
Touch T5 = 39, 64, 65, 65, 65,  
Camera Ready! Use 'http://192.168.1.122' to connect
Start a PIR
zcam / avi / ftp / ftp2 / loop 
0 / 0 / 2676 / 2676 / 0  
Internal Total heap 292064, internal Free Heap 90740
SPIRam Total heap   4194140, SPIRam Free Heap   1506140
ChipRevision 1, Cpu Freq 240, SDK Version v3.3.4-432-g7a85334d8
Avi Writer / Camera / Ftp 
2544 / 452 / 3420
----
Total space: 967MB
Used space: 790MB
Nothing deleted, 81.7% disk full
the loop, core 1, priority = 1
Taking a picture for file ...
File saved: /sdcard/20210311/espcam 2021-03-11 21.04.10 svga_Q12_I100_L15_S1.jpg
Taking a picture for telegram...
Sending Photo Telegram, bytes: 10400

Photo telegram failed ><
z 
Total space: 967MB
Used space: 790MB
Nothing deleted, 81.7% disk full
Starting an avi 

File name will be >/sdcard/20210311/espcam 2021-03-11 21.04.11 svga_Q12_I100_L15_S1.avi<

Recording 150 video frames ...

I testet my token and id with a example provided by the Universal Arduino Telegram Bot library and it worked.

FR: microphone, mqtt

Great development so far James, thank you!
I have some ideas, maybe you like it:

  • implement sound recording via mems microphone (i guess one has to decide between video or audio...)
    -- trigger audio / video recording via noise level (maybe basic motion detection is also possible?)
    -- a sync mechanism to start recording on multiple devices at once (so one can later mux the video and audio (see next point mqtt))

  • mqtt interface (eg: request pictures as payload, change parameters, start / stop recordings, noise / motion alarm, etc)

V89 - Time gap between sending foto by BOT and starting AVI to long

The time from sending BOT to starting avi is to long. How to overcome that?
During night Wifi is switched off and on in the morning controlled by internal time. At that time Internet_Enable is false.
What happen with time during deepsleep because without Wifi NTP is not available.?

Camera-based motion detection transformation successfully

I transformed and tested your project and successfully implemented motion detection.
Thank you in advance for this project.

But I currently face a small problem, which is often the "Queue Full" problem. My recording mode is 10fpsSVGA, while detecting movement every 100ms. Is it possible that I have touched the bottleneck of ESP32? Is it possible further optimization.

This is my code:https://github.com/asjdf/ESP32CAMmotion_detection/tree/master/Tested%20procedures/test2

PIR stay active

PIR Touch is working fine.

But if i trigger a PIR signal with 3.3v and 1k resistor on Pin13 first there were no massage about triggered pir on console.
After i erase flash and reuploading it worked once but now pir stays triggered. and does not reset.

I triggered PIR signal with a wire and 1k resistor and no pir sensor but i think it will be the same.

And second issues is i can connect to ftp but there are no files. if i look into the sd card there are files.

Does not record after disabling telegram

If I comment out //#define include_telegram inside settings.h it never writes to the sd card again.

I can start a new recording, the serial output says its recording but its

zzzstarting recording
zWrite settings in the EPROM
Writing to EPROM ...
Put took 8 ms, bytes = 60
do_start Starting a new AVI
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

Telegram Bot not working

Hi,

last version's re-write is really great, much cleaner with the separate settings. Great job!

For the Telegram bot - can't seem to get it to work. It says sucessfull in the serial monitor but nothing is received.
The code comments say "and then get your telegram number" - what number?

For BOTme - tried my phone number including the country code, tried my user name without the @, tried the bot's name.

Looked at https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot too ...

Pretty sure it is some dumb mistake :)

Best,

-T

Settings currently looks like this (not real credentials of course).

...
RTC_DATA_ATTR int EnableBOT = 1;
#define BOTtoken  "3xxx....xxb7"   // get your own bot and id at telegram.org 
#define BOTme     "33123468"
...

parameters for short video

Thanks for this project ( v89 ). You can use it in many different ways as it seems to me. I have installed it and it works well. But I want to use it in such a way that I get an information plus image via "Telegram" when the PIR is activated and then only a short video of 1-2 minutes is recorded. Can you give me the example parameters with which I can achieve this goal.
Thanks
Burkadius

Modify xspeed parameter for long timelapse

The xspeed parameter is the multiple of fps to playback the video.

If you are taking pictures at 10,000 ms interval (0.1 fps), and you want them to play at 24 fps (or 41.7 ms interval), then xspeed would be 24 / .1 = 240 or 10,000 / 41.7.

So I think you need to speed up your 2 frames per hour to a xspeed factor of 43,200 ... I think.

I haven't tried that -- I get a little nervous in power supplies and people knocking over the camera to stretch beyond 1 hour, before closing the files, writing the index, and starting a new video. My tomato videos run for 1 hour at 50x speed, and then I paste the daylight hours together and multiply it by another 32 times for 1600x. One day in 30 seconds. But grass is a whole new world of slowness! :-)

@bencooney

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.