-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Config support] ESP32 CAM with esphome doesn't work with go2rtc restream #292
Comments
You'll need to enable additional logs to see why it's failing. That being said, I'd suggest just having the http without ffmpeg: and have a separate ffmpeg stream with the camera name go2rtc:
streams:
doorbell:
- http:https://192.168.1.11:8080
- ffmpeg:doorbell#video=h264#hardware |
I've now tried that format, still no stream. Added "logger: default:debug" to config, and this is doorbell related errors.
|
You'll need to set logs for exec to trace level |
I'd be happy to do that, unsure how? Is it docker env tag or? Also, I've found this: blakeblackshear/frigate#4171 |
|
Got it! Thanks. Here is the log:
|
Your GPU does not support an mjpeg profile with that resolution so you'll need to use it without hardware |
Yeah, I've tried it without hardware and it didn't work untill I've put 800x600 and 640x480. Now even gpu acceleration works, I have same usage as with H264 cams. Quality is quite bad and it's 5fps but just wanted to know if it would work.
Thank you, that log tracing sure is usefull :D |
@Ginpachi98 You wouldn't happen to be able to post your configs would you? I am trying to get the same thing working and I can't figure out how you solved this. |
The idea is that esp32 cam has 800x600; important esphome yaml part:
and docker:
|
EDIT: Still does not work properly. I don't know, I am no longer interested wasting more time on ESPCAMs :/ Spent few hours troubleshooting why ESP32-CAM from AliExpress does not work properly with Frigate (go2rtc). It's simple - turns out it must not go beyond When you go to ESPHome dashboard, open wireless logs and find this:
As you can see, it's close enough to 5fps, which is great - camera is able to catch up with requested framerate. If you find yourself watching it be like 2-3fps - that means it cannot produce frames on time and therefore go2rtc hungs/crashes because stream arrives out of order... Restarting go2rtc fixes it for a few seconds and freezes again. It's not stable and you have to reduce throughput of the stream - either reduce resolution, fps or both. Here is my config for those who are interesting. Intel nuc, using vaapi hw accel. Frigate part: go2rtc:
streams:
cam01:
- "http:https://123.123.123.123:8080/"
- "ffmpeg:cam01#video=h264#hardware" ESPHome part: esp32_camera_web_server:
- port: 8080
mode: stream
esp32_camera:
external_clock:
pin: GPIO0
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
pixel_clock_pin: GPIO22
power_down_pin: GPIO32
name: espcam01
resolution: 640x480
max_framerate: 5fps |
After playing around a bit more, I've achieved "something-works" kind of state. ESPHome config part. I am using almost max resolution with 1fps (that's my use case). Also pay attention to esp32_camera_web_server:
- port: 8080
mode: stream
esp32_camera:
external_clock:
pin: GPIO0
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
pixel_clock_pin: GPIO22
power_down_pin: GPIO32
name: espcam01
resolution: 2560x1440
max_framerate: 1fps
jpeg_quality: 15
vertical_flip: False
horizontal_mirror: False Frigate config. Note those go2rtc:
streams:
cam01:
- "http:https://123.123.123.123:8080"
- "ffmpeg:cam01#video=h264#hardware#raw=-avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1"
webrtc:
candidates:
- 123.123.123.123:8555
- example.com:8555
- stun:8555
cameras:
cam01:
ffmpeg:
inputs:
- path: rtsp:https://127.0.0.1:8554/cam01
roles: [detect] I would say - give it some time. If still does not work - restart something. It's a hit or miss with ESPCAM, but once it works - it works without issues. |
After more and more digging, I've came to this conclusion: ESP32 CAM stream is very unstable and no matter how hard you try - recording it is going to be almost impossible. I think that's the problem with all mjpeg streams. As an alternative, it is possible to (fully successfully) use ESP32 CAM without go2rtc:
streams:
cam01:
- "http:https://123.123.123.123:8080"
cameras:
cam01:
ffmpeg:
inputs:
- path: http:https://127.0.0.1:1984/api/stream.mjpeg?src=cam01
roles: [detect]
input_args: -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -c:v mjpeg
# Hardware accel disabled, otherwise bottom half of the mjpeg stream is green
# ffmpeg:
# hwaccel_args: preset-vaapi In HomeAssistant Frigate card use this - directly from go2rtc which re-streams raw mjpeg stream: type: custom:frigate-card
cameras:
- camera_entity: camera.cam01
live_provider: go2rtc
id: cam01
title: cam01
go2rtc:
modes:
- mjpeg
stream: cam01 In ESPHome somehow this started to work just fine too! resolution: 2560x1440
max_framerate: 1fps
jpeg_quality: 10 |
So I guess this is my last message with conclusions... 🤷 Do not record ESP32 CAM streamEverything seem to work fine with go2rtc and Frigate simply if you don't enable Here is my Frigate config that works great! go2rtc:
streams:
cam01:
- "http:https://123.123.123.123:8080"
cameras:
cam01:
ffmpeg:
inputs:
- path: http:https://127.0.0.1:1984/api/stream.mjpeg?src=cam01
roles: [detect]
input_args: -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -c:v mjpeg
Disable "auto" for aec and agc to improve stabilityWhat if I tell you that you can enable max resolution at stable 1 FPS? Well, the key factors that causes such instabilities are camera's automations, called
This might not be necessary if you don't need maximum camera resolutions. Or even in some cases - you need them both set to Disable hardware acceleration (if you see half screen green).Example: https://www.reddit.com/r/frigate_nvr/comments/176kzon/half_of_the_image_overlayed_in_green/ Disabling hardware acceleration (in Frigate) fixed this for me. Re-stream to HomeAssistant (Frigate card):Here is what worked for me the best - latency almost like direct connection to camera: type: custom:frigate-card
cameras:
- camera_entity: camera.cam01
live_provider: go2rtc
id: cam01
title: cam01
go2rtc:
modes:
- mjpeg
stream: cam01 |
@erkexzcx I'm using this version: https://github.com/rzeldent/esp32cam-rtsp, Have you used this? I get |
I'm using frigate docker 12.0.9; two h264 cams with rtsp work very nice with radeonsi gpu and libva drivers, but mjpeg on ESP32 cam doesn't work with go2rtc. Didn't find any similar issues, hence I'm posting here. Here are some of the logs:
Here is config.yml
Stream is working when I access it with IP address;
The text was updated successfully, but these errors were encountered: