Home

Awesome

ESP32CAM-RTSP

Platform IO CI

Simple RTSP, HTTP JPEG Streamer and image server with configuration through the web interface.

[!IMPORTANT]
New branch available! Here branch: develop This branch supports all the current devices and the Seeed Studio Xiao esp32s3! Please use this and let me know if this works for you!

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.

Supported protocols

This software supports the following ESP32-CAM (and alike) modules:

The software provides a configuration web server, that can be used to:

The software provides contains also a mDNS server to be easily discoverable on the local network. It advertises HTTP (port 80) and RTSP (port 554)

Required

Boards

There are a lot of boards available that are all called ESP32-CAM. However, there are differences in CPU (type/speed/cores), how the camera is connected, presence of PSRAM or not... To select the right board use the table below and use the configuration that is listed below for your board:

BoardImageCPUSRAMFlashPSRAMCameraSite
Espressif ESP32-Wrover CAMimgESP32520KB4Mb4MBOV2640
AI-Thinker ESP32-CAMimg imgESP32520KB4Mb4MBOV2640https://docs.ai-thinker.com/esp32-cam
Espressif ESP-EYEimgESP32520KB4Mb4MBOV2640
Espressif ESP-S3-EYEimgESP32-S3520KB4Mb4MBOV2640https://www.espressif.com/en/products/devkits/esp-eye/overview
LilyGo camera moduleimgESP32 Wrover520KB4Mb4MBOV2640 / OV5640
LilyGo SimcamimgOV2640
LilyGo TTGO-T CameraimgOV2640
M5Stack ESP32CAMimgESP32520Kb4Mb-OV2640Microphonehttps://docs.m5stack.com/en/unit/esp32cam
M5Stack UnitCamimg imgESP32-WROOM-32E520KB4Mb-OV2640https://docs.m5stack.com/en/unit/unit_cam
M5Stack CameraimgESP32520Kb4Mb-OV2640https://docs.m5stack.com/en/unit/m5camera
M5Stack Camera PSRAMimgESP32520Kb4Mb4MbOV2640https://docs.m5stack.com/en/unit/m5camera
M5Stack UnitCamS3img imgESP32-S3-WROOM-1-N16R8520Kb16Mb8MbOV2640https://docs.m5stack.com/en/unit/Unit-CamS3
Seeed studio Xiao ESP32S3 SenseimgESP32-S3R8520KB8Mb8MBOV2640Microphonehttps://www.seeedstudio.com/XIAO-ESP32S3-Sense-p-5639.html

Installing and running PlatformIO

PlatformIO is available for all major operating systems: Windows, Linux and MacOS. It is also provided as a plugin to Visual Studio Code. More information can be found at: https://docs.platformio.org/en/latest/installation.html below the basics.

Install Visual Studio Code and install the PlatformIO plugin.

Putting the ESP32-CAM in download mode

ESP32-CAM-MB

When using the ESP32-CAM-MB board, press and hold the GP0 button on the ESP32-CAM-MB board. Then press short the reset button (on the inside) on the ESP32-CAM board and release the GP0 button. This will put the ESP32-CAM board in download mode.

FTDI adapter

When using an FTDI adapter, make sure the adapter is set to 3.3 volt before connecting. Use the wiring schema below.

ESP FTDI wiring

After programming remove the wire to tge GPIO0 pin to exit the download mode.

Compiling and deploying the software

Open a command line or terminal window and clone this repository from GitHub.

git clone https://github.com/rzeldent/esp32cam-rtsp.git

go into the folder

cd esp32cam-rtsp

Next, the firmware has to be build and deployed to the ESP32. There are two flavours to do this; using the command line or the graphical interface of Visual Studio Code.

Using the command line

Make sure you have the latest version of the Espressif toolchain.

pio pkg update -g -p espressif32

First the source code has to be compiled to build all targets

pio run

if only a specific target is required, for example the esp32cam_ttgo_t_journal type:

pio run -e esp32cam_ttgo_t_journal

When finished, firmware has to be uploaded. Make sure the ESP32-CAM is in download mode (see previous section) and type:

 pio run -t upload

or, again, for a specific target, for example esp32cam_ai_thinker

pio run -t upload -e esp32cam_ai_thinker

When done remove the jumper when using a FTDI adapter or press the reset button on the ESP32-CAM. To monitor the output, start a terminal using:

 pio device monitor

Using Visual studio

Open the project in a new window. Run the following tasks using the Terminal -> Run Task or CTRL+ALT+T command in the menu (or use the icons below on the toolbar). Make sure the ESP32-CAM is in download mode during the uploads.

To monitor the behavior run the task, run: PlatformIO: Monitor (esp32cam)

Setting up the ESP32CAM-RTSP

After the programming of the ESP32, there is no configuration present. This needs to be added. To connect initially to the device open the WiFi connections and select the WiFi network / access point called ESP32CAM-RTSP. Initially there is no password present.

After connecting, the browser should automatically open the status page. In case this does not happens automatically, connect to http://192.168.4.1. This page will display the current settings and status. On the bottom, there is a link to the config. Click on this link.

This link brings up the configuration screen when connecting fot the first time.

Configuration screen

Configure at least:

When finished press Apply to save the configuration. The screen will redirect to the status screen. Here it is possible to reboot the device so the settings take effect. It is also possible to restart manually by pressing the reset button.

Connecting to the configuration

After the initial configuration and the device is connected to an access point, the device can be configured over http.

When a connection is made to http://esp32cam-rtsp the status screen is shown.

Status screen

In case changes have been made to the configuration, this is shown and the possibility to restart is given.

Clicking on the change configuration button will open the configuration. It is possible that a password dialog is shown before entering. If this happens, for the user enter 'admin' and for the password the value that has been configured as the Access Point password.

Connecting to the RTSP stream

RTSP stream is available at: rtsp://esp32cam-rtsp.local:554/mjpeg/1. This link can be opened with for example VLC.

Connecting to the JPEG motion server

The JPEG motion server server is available using a normal web browser at: http://esp32cam-rtsp.local:/stream.

Connecting to the image server

The image server server is available using a normal web browser at: http://esp32cam-rtsp.local:/snapshot.

:bangbang: Please be aware that there is no password present!. Everybody with network access to the device can see the streams or images! Beware of :trollface:!

API

There is a minimum API present to perform some tasks using HTTP requests. For some requests authentication is required. The authentication used is basic authentication. The user is always admin and the password the access point key.
If using a browser, remember that the authentication is stored in the browser session so needs to be entered only once.

The URLs are below:

GET: /restart

Calling this URL will restart the device. Authentication is required.

GET: /config

Calling this URL will start the form for configuring the device in the browser. Authentication is required.

GET: /snapshot

Calling this URL will return a JPEG snapshot of the camera in the browser. This request can also be used (for example using cURL) to save the snapshot to a file.

Issues / Nice to know

Power

Make sure the power is 5 volts and stable, although the ESP32 is a 3.3V module, this voltage is created on the board. If not stable, it has been reported that restarts occur when starting up (probably when power is required for WiFi). The software disables the brown out protection so there is some margin in the voltage. Some people suggest to add a capacitor over the 5V input to stabilize the voltage.

PSRAM / Buffers / JPEG quality

Some esp32cam modules have additional ram on the board. This allows to use this ram as frame buffer. The availability of PSRAM can be seen in the HTML status overview.

Not all the boards are equipped with PSRAM:

BoardPSRAM
WROVER_KIT8Mb
ESP_EYE8Mb
ESP32S3_EYE8Mb
M5STACK_PSRAM8Mb
M5STACK_V2_PSRAMVersion B only
M5STACK_WIDE8Mb
M5STACK_ESP32CAMNo
M5STACK_UNITCAMNo
M5STACK_UNITCAMS38Mb
AI_THINKER8Mb
TTGO_T_JOURNALNo
ESP32_CAM_BOARD?
ESP32S2_CAM_BOARD?
ESP32S3_CAM_LCD?

Depending on the image resolution, framerate and quality, the PSRAM must be enabled and/or the number of frame buffers increased to keep up with the data generated by the sensor. There are (a lot of?) boards around with faulty PSRAM. If the camera fails to initialize, this might be a reason. See on Reddit. In this case disable the use of PSRAM in the configuration and do not use camera modes that require PSRAM,

For the setting JPEG quality, a lower number means higher quality. Be aware that a very high quality (low number) can cause the ESP32 cam to crash or return no image.

The default settings are:

Camera module

Be careful when connecting the camera module. Make sure it is connected the right way around (Camera pointing away from the board) and the ribbon cable inserted to the end before locking it.

Credits

esp32cam-rtsp depends on PlatformIO, Bootstrap 5 and Micro-RTSP by Kevin Hester.

Change history