mirror of
https://github.com/rzeldent/esp32cam-rtsp.git
synced 2025-11-12 03:06:22 +00:00
Added JPEG Motion streaming
This commit is contained in:
19
README.md
19
README.md
@@ -2,14 +2,29 @@
|
||||
|
||||
[](https://github.com/rzeldent/esp32cam-rtsp/actions/workflows/main.yml)
|
||||
|
||||
Simple [RTSP](https://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol) server.
|
||||
Simple [RTSP](https://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol), [HTTP JPEG Streamer](https://en.wikipedia.org/wiki/Motion_JPEG) and server.
|
||||
Easy configuration through the web interface.
|
||||
|
||||
Flashing this software on a ESP32CAM module will make it a **RTSP streaming camera** server.
|
||||
Flashing this software on a ESP32CAM module will make it a **RTSP streaming camera** server, a **HTTP Motion JPEG streamer*** and a **HTTP image server**.
|
||||
|
||||
### RTSP
|
||||
The RTSP protocol is an industry standard and allows many CCTV systems and applications (like for example [VLC](https://www.videolan.org/vlc/)) to connect directly to the ESP32CAM camera stream.
|
||||
It is also possible to stream directly to a server using [ffmpeg](https://ffmpeg.org).
|
||||
This makes the module a camera server allowing recording and the stream can be stored on a disk and replayed later.
|
||||
|
||||
The URL is rtsp://<ip address of the module>:554/mjpeg/1
|
||||
|
||||
### HTTP Motion JPEG
|
||||
The HTTP JPEG streamer makes it possible to watch the camera stream directly in your browser.
|
||||
|
||||
The URL is http://<ip address of the module>/stream
|
||||
|
||||
### HTTP image server
|
||||
The HTTP Image server returns an HTTP jpeg image of the camera.
|
||||
|
||||
The URL is http://<ip address of the module>/snapshot
|
||||
|
||||
|
||||
This software supports the following ESP32-CAM (and alike) modules:
|
||||
|
||||
- ESP32CAM
|
||||
|
||||
@@ -273,14 +273,17 @@
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<span>
|
||||
The camera RTSP stream can be found at:
|
||||
<a href="rtsp://{{IpV4}}:{{RtspPort}}/mjpeg/1">rtsp://{{IpV4}}:{{RtspPort}}/mjpeg/1</a>
|
||||
RTSP camera stream: <a href="rtsp://{{IpV4}}:{{RtspPort}}/mjpeg/1">rtsp://{{IpV4}}:{{RtspPort}}/mjpeg/1</a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span>
|
||||
A snapshot of the camera can be found at:
|
||||
<a href="http://{{IpV4}}/snapshot">http://{{IpV4}}/snapshot</a>
|
||||
JPEG Motion stream: <a href="http://{{IpV4}}/stream" target="_blank">http://{{IpV4}}/stream</a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span>
|
||||
Snapshot of the camera: <a href="http://{{IpV4}}/snapshot " target="_blank">http://{{IpV4}}/snapshot</a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
File diff suppressed because one or more lines are too long
33
src/main.cpp
33
src/main.cpp
@@ -213,6 +213,36 @@ void handle_snapshot()
|
||||
web_server.sendContent(fb, fb_len);
|
||||
}
|
||||
|
||||
#define STREAM_CONTENT_BOUNDARY "123456789000000000000987654321"
|
||||
|
||||
void handle_stream()
|
||||
{
|
||||
log_v("handle_stream");
|
||||
if (camera_init_result != ESP_OK)
|
||||
{
|
||||
web_server.send(404, "text/plain", "Camera is not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
log_v("starting streaming");
|
||||
char size_buf[12];
|
||||
auto client = web_server.client();
|
||||
client.write("HTTP/1.1 200 OK\r\nAccess-Control-Allow-Origin: *\r\nContent-Type: multipart/x-mixed-replace; boundary=" STREAM_CONTENT_BOUNDARY "\r\n");
|
||||
while (client.connected())
|
||||
{
|
||||
client.write("\r\n--" STREAM_CONTENT_BOUNDARY "\r\n");
|
||||
cam.run();
|
||||
client.write("Content-Type: image/jpeg\r\nContent-Length: ");
|
||||
sprintf(size_buf, "%d\r\n\r\n", cam.getSize());
|
||||
client.write(size_buf);
|
||||
client.write(cam.getfb(), cam.getSize());
|
||||
}
|
||||
|
||||
log_v("client disconnected");
|
||||
client.stop();
|
||||
log_v("stopped streaming");
|
||||
}
|
||||
|
||||
void handle_flash()
|
||||
{
|
||||
log_v("handle_flash");
|
||||
@@ -402,6 +432,9 @@ void setup()
|
||||
web_server.on("/restart", HTTP_GET, handle_restart);
|
||||
// Camera snapshot
|
||||
web_server.on("/snapshot", HTTP_GET, handle_snapshot);
|
||||
// Camera stream
|
||||
web_server.on("/stream", HTTP_GET, handle_stream);
|
||||
|
||||
// Camera flash light
|
||||
web_server.on("/flash", HTTP_GET, handle_flash);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user