GithubHelp home page GithubHelp logo

bonbon2106 / esp32-cam_audio Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spawn451/esp32-cam_audio

0.0 0.0 0.0 621 KB

Stream video and audio with ESP32-CAM

C++ 22.78% C 76.21% HTML 1.01%

esp32-cam_audio's Introduction

ESP32-CAM_Audio

This sketch allows you to use the ESP32-CAM as an MJPEG & WAV streaming webserver. Audio (your voice) is captured by a microphone and stream to the WAV format.

The code was tested with :

Camera model Camera module Microphone
AI-Thinker ESP32-CAM OV2640
OV5640
INMP441 MEMS microphone
XIAO_ESP32S3 OV2640
OV5640
Integrated PDM microphone

The sketch uses the basic Arduino CameraWebServer example to which I added an audio server.

ESP32-CAM Urls :

Video + Audio stream is made as an example but is not ideal because there is an audio delay related to the web browser buffer. I recommend using go2rtc streaming application in order to have almost ZERO latency.

Wiring

Alt text

Sketch configuration

Configure your WiFi network credentials.

const char* ssid = "ssid";
const char* password = "password";

Edit the audio_server.h file.

CAMERA_MODEL_AI_THINKER

//select the pins according to your connections
#define I2S_WS            2 
#define I2S_SCK           14 
#define I2S_SD            15 

#define I2S_PORT          I2S_NUM_1
#define SAMPLE_BITS       32
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
.channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT,

CAMERA_MODEL_XIAO_ESP32S3

#define I2S_WS            42 
#define I2S_SCK           -1
#define I2S_SD            41

#define I2S_PORT          I2S_NUM_0
#define SAMPLE_BITS       16
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_PDM),
.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,

Usage

Here is the method I use to access the streams from a web page. In order to have a single point for broadcasting video and audio with low latency, I use go2rtc which is a camera streaming application.

Video and audio source stream configuration

You must edit the go2rtc.yaml configuration file.This can be done directly from the web interface.

  1. Go to the Config menu.
  2. Add the ESP32-CAM stream links.
  3. Click the Save & Restart button.

Alt text

streams:

  ESP32-CAM_video: http://192.168.10.55:81/stream
  ESP32-CAM_audio: http://192.168.10.55:82/audio#audio=opus

Alternative to avoid creating a custom HTML web page.

streams:

  ESP32-CAM:
    - ffmpeg:http://192.168.10.55:81/stream#video=h264
    - ffmpeg:http://192.168.10.55:82/audio#audio=opus

Link to the stream: https://go2rtc.local/stream.html?src=ESP32-CAM

Alt text

Custom HTML page

The custom html page contains two Iframes that allow video and audio to be combined. Adapt the ESP32CAM_stream.html file with the following links :

Alt text

Home Assistant

It is also possible to integrate into Home Assistant.

Webpage card without custom HTLM page.

type: iframe
url: https://go2rtc.local/stream.html?src=ESP32-CAM
aspect_ratio: 100%

esp32-cam_audio's People

Contributors

spawn451 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.