Hi!
I would like to stream video from my camera to my phone, and idea is ESP32 in softAP mode, hosting web page that show output from camera.
I have configured softAP, and started basic webserver. When I try to enter 192.168.4.1:80/remote (configured uri), it says that page don't exist. Do I have to wrap everything in some sort of html, and then host it?
Web page hosted on ESP32
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Web page hosted on ESP32
Hard to say without knowing the code you use. Sorry, we don't have a crystal ball...
Re: Web page hosted on ESP32
Actually webserver and softAP is working. Problem is related to ESP-CAM lib, from espressif.
When I query server, in make monitor error is shown:
When saving camera buffer to SD, there were no errors.
My cam stream code:
When I query server, in make monitor error is shown:
Code: Select all
E (59477) camera: Failed to get the frame on time!
E (59477) camera.c:: Camera capture failed
W (59477) httpd_uri: httpd_uri: uri handler execution failed
My cam stream code:
Code: Select all
esp_err_t video_stream_handler(httpd_req_t *req){
camera_fb_t * fb = NULL;
esp_err_t res = ESP_OK;
size_t _jpg_buf_len;
uint8_t * _jpg_buf;
char * part_buf[64];
static int64_t last_frame = 0;
if(!last_frame) {
last_frame = esp_timer_get_time();
}
res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);
if(res != ESP_OK){
return res;
}
while(true){
fb = esp_camera_fb_get();
if (!fb) {
ESP_LOGE(TAG, "Camera capture failed");
res = ESP_FAIL;
break;
} else {
if(fb->format != PIXFORMAT_JPEG){
bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len);
if(!jpeg_converted){
ESP_LOGE(TAG, "JPEG compression failed");
esp_camera_fb_return(fb);
res = ESP_FAIL;
}
} else {
_jpg_buf_len = fb->len;
_jpg_buf = fb->buf;
}
}
if(res == ESP_OK){
res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));
}
if(res == ESP_OK){
size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len);
res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen);
}
if(res == ESP_OK){
res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len);
}
if(fb->format != PIXFORMAT_JPEG){
free(_jpg_buf);
}
esp_camera_fb_return(fb);
if(res != ESP_OK){
break;
}
int64_t fr_end = esp_timer_get_time();
int64_t frame_time = fr_end - last_frame;
last_frame = fr_end;
frame_time /= 1000;
ESP_LOGI(TAG, "MJPG: %uKB %ums (%.1ffps)",
(uint32_t)(_jpg_buf_len/1024),
(uint32_t)frame_time, 1000.0 / (uint32_t)frame_time);
}
last_frame = 0;
return res;
}
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Web page hosted on ESP32
Could be a performance thing: the http/wifi/... stack is too busy with sending data to allow the camera subsystem to get the next frame properly. You could try moving the various tasks to a different core and see if that helps.
Who is online
Users browsing this forum: Bing [Bot] and 121 guests