jameszah / ESP32-CAM-Video-Telegram

Record avi video on ESP32-CAM and send to Telegram on event or request
GNU General Public License v3.0
113 stars 26 forks source link

Video upload to telegram slow rate #34

Open mlegnari opened 1 year ago

mlegnari commented 1 year ago

Hi! When ESP32CAM finishes the video and starts uploading I noticed that it takes a long time (150 seconds +- or 19kb/s) to upload the 2.9MB video.

I'm using very fast internet 300MB download/upload, at first I tried another connection without success, and I also tried 2 more modules from other suppliers.

Is this delay normal?

bmburi commented 1 year ago

mine does the same! does the pir pic works for u mine sends an old pic that has been taken previously when it senses motion!

mlegnari commented 1 year ago

@bmburi The pir works correctly, as soon as it detects it, it takes a photo of approximately 45kb in size, and sends it in a short time, 5 seconds approximately, soon after it films (45 seconds at 2fps) there it generates the 2.9MB file (fills all reserved PSRAM ) this upload is time consuming.

I also noticed that when there are packet losses (5% or more) the upload can be interrupted and does not finish, I tested it on a bad 4G internet and had this problem.

bmburi commented 1 year ago

for me whenever senses motion the pic is old but the clip is okay

mlegnari commented 1 year ago

@bmburi what would an old photo be? after the pir it shows you a photo on telegram approximately how many seconds ago?

For example: pir sensor triggered at 12:00h:00s, you will receive a photo on telegram at 12:00h:20s. Or are you getting a very old photo that has nothing to do with it?

bmburi commented 1 year ago

lets say i send a command to take a picture. it will come the pic. after when it senses the pir it sends me that pic instead of the new one!

FBMinis commented 1 year ago

Getting an old photo happened to my while using AsyncTelegram2 library in another project. It was fixed by changing library and board version.

mlegnari commented 1 year ago

@jameszah As for the low transfer rate, is it something common? How long does your ESP32CAM take to upload the video? Do you have any suggestions how to change the send block size from 512byte etc?

jameszah commented 1 year ago

The "old-photo" issue is a old problem when the driver changed -- it is not fixed here apparently -- i think it is fixed the the test version.

The transfer speed bottleneck is between the esp32 and the router -- router to the telegram servers in Switzerland is probably quite fast.

I would guess the 3 MB file is 90 seconds or so. The higher the rssi number the quicker it should go (higher = lower negative log number)

ESP32 is max like 3 mega-bits-per second, but doing the tsl processing and waiting for the reply from Switzerland slows things down.

Here is some chat about speed -- non-tls between esp32 and computer, through the router, in the same room.

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

https://github.com/jameszah/ESP32-CAM-Video-Recorder-junior/raw/master/v58/2mbps.jpg

https://github.com/jameszah/ESP32-CAM-Video-Telegram/blob/b9df4519c2aba9e8b74cc923e19858b832ec3b13/v9.6/ESP32-CAM-Video-Telegram_9.6/UniversalTelegramBot.h#L142

Increasing the blocksize might help, but probably not enough free ran to do much.

bmburi commented 1 year ago

its fixed for me by the code u made change the old pic issue

FBMinis commented 1 year ago

Regarding the slow upload, I recently purchased a 6th camera that had trouble connecting to wifi and send picture+video. I could see the led blinking while capturing but the Serial Monitor showed the camera upload would end and I'd receive nothing. The test conditions were the same as with the previous 5 cameras. I decided to keep it simple and make another test with the CameraWebServer example included in the ArduinoIDE, what I observed was a difficulty to connect, extremely low framerate and sudden crashes.

Both the CameraWebServer example and JamesZah worked acceptably after I adopted this workaround:

setting config.xclk_freq_hz = 8000000;

https://github.com/espressif/arduino-esp32/issues/4655 https://github.com/espressif/arduino-esp32/issues/5834 https://community.m5stack.com/topic/3649/unitcam-hw-issue-cannot-stream-video/11 https://www.youtube.com/watch?v=MBOGWK5qrkw

It affects video playback but I got a refund from the seller: https://pt.aliexpress.com/item/1005004749706289.html (purchased the version without lens for €4.30 at the time)

hakam007 commented 10 months ago

its fixed for me by the code u made change the old pic issue

please help in this regard ..I am still facing the old pic issue

jameszah commented 10 months ago

Are you using the installer, or compiling the 9.6 version? Which esp32-arduino board library? I don't seem to have updated since 2.06 ... or 2.09 on another ide .... now it is 2.11

I'll have a look at it.

hakam007 commented 10 months ago

On Sat, 19 Aug 2023 at 7:47 PM, jameszah @.***> wrote:

Are you using the installer, or compiling the 9.6 version? Which esp32-arduino board library? I don't seem to have updated since 2.06 ... or 2.09 on another ide .... now it is 2.11

I'll have a look at it.

— Reply to this email directly, view it on GitHub https://github.com/jameszah/ESP32-CAM-Video-Telegram/issues/34#issuecomment-1684987301, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3EQR7UCUYDTGBTQI7PZ4XDXWDDG5ANCNFSM6AAAAAASBTXCTY . You are receiving this because you commented.

thanks a lot sir, I modified the code that you suggested in GitHub , now it works fine , you are really doing great work 👏👏🙏🙏😍😍