6

I am doing research for a project in which I need to play with camera streams. After multiple hit and trails and googling I am not getting even close to the solution for streaming ESP-32 Camera stream to my own RMTP server directly.

Already tried solutions:

1) I have tried re-streaming of ESP-32-cam with Raspberry pi, that works well but not something I am looking for {discarded because do not want to use Raspberrypi for restreaming purposes} enter image description here

2) ESP-32-cam: Record and FTP transfer with time triggers (Not tried but believed that it is not a good approach). {discarded because it is not realtime}

3) ESP32 Try to send image file to php with HTTPClient I have tried but it works for images only and secondly the code is executed in loop function so ther is a long delay due to saving and posting operations.

Please note: I am not looking at the solution in which ESP-32 cam acts as stream server and browser can connect to it like : https://www.hackster.io/BnBe_Club/9-rtsp-video-streamer-using-the-esp32-cam-board-8832b4 enter image description here

I have already tried it and it works well but not for the usecase which involves streaming to RTMP server without restreaming.

**

I want to achieve ESP-32 CAM can post / stream directly to the RTMP cloud hosted server, technically it seems to be possible because ESP-32 cam has support for connecting to wifi and access the cloud server

** enter image description here

On google, I found a similar thread : https://forum.arduino.cc/index.php?topic=634605.0 The guy with solution is not interested in sharing it.

may be some modification required in below code MAY BE ref: https://github.com/espressif/esp32-camera

Ishaan Puniani
  • 646
  • 2
  • 10
  • 23

1 Answers1

1

You should read (and understand) your posted links.
There are two options. One is used by the rtsp library where the Arduino acts as rtsp server so programs like vlc can decode the stream on the desktop.
Or the BnBe solution where the Esp32cam acts as client and servers like youtube can receive the stream and decode it.
The ESP is in this scenario via AP connected to the internet. The browser component may be used to configure it.
Imho there is no third solution in a client server scenario (One acts as client the other is server). Read the code of the BnBe solution carefully. If you want to hardcode your config - easy doable.
Your remark qoute: "usecase which involves streaming to RTMP server without restreaming" sorry I cannot see that happening at least in the code I have
What you mean perhabs is that the authors get the stream from the cam (method esp_camera_fb_get()) thats not "restreaming" thats due to the closed source by espressif the only way to access the prepared camera stream. If you do not like this you have to invest into other hardware.
You edited your question with the graphic. This is what the BnBe solution does! So NO restreaming.
The OP wants to send the result of the espressif function esp_camera_fb_get() directly to the rtmp cloud service. This is technically not possible, because the API only gives access to grab a frame buffer encoded as mpeg (bassically single jpgs glued together). So you have to have your frame buffer converted to a valid rtmp stream. Even if you look into the datasheet of the OV2640 you will see the source is closed and only API access to the firmware is possible. So except for reverse engeniering there is no possibility.
Use the BnBe solution, it works and saves you 1/2 year of development you can improve it if you are a good coder but forget about muliple streams The ESP32 CPU barley handles one!
-> look especially into the code of CRtspSession.h and CRtspSession.cpp as well as OV2640.h and OV2640.cpp (there you'll find all API functions of the cam module)

Codebreaker007
  • 2,911
  • 1
  • 10
  • 22
  • Hello, Thanks for the response, I have added images to clarify about restreaming, For the AP mode, the access is limited to single location only. "sorry I cannot see that happening at least in the code I have" -- Yes it is not happening but eventually your code is not sending the stream to internet facing server. I have tried to comprehend it in the first picture. Basically I want to transfer "esp_camera_fb_get()" to colud RTMP server – Ishaan Puniani Mar 30 '20 at 22:41
  • See my edit This (picture 2) is exactly the BeBe solution. Picture 1 is the rtmp libraray function. So PLEASE read the code of the BeBe (especially the streamer files in the src dir ) and make the nescessary changes in the defines for your use case - It works! – Codebreaker007 Mar 30 '20 at 23:09
  • Hello @codebreaker. in your comments you are mentioning BeBe solution ,,,, did you mean BnBe solution? or please share the link. secondly I am looking for Solution that is referred in picture 3. – Ishaan Puniani Mar 31 '20 at 14:27
  • Sorry see my edit in my answer to give you directions yes its BnBe of course, You have of course to adapt the ino to your use case, the scr files (adapted lib files) can do it – Codebreaker007 Mar 31 '20 at 15:29
  • https://github.com/enesbcs/ESP32_RTSP_Cam/blob/master/lib/Micro-RTSP-Multi/CStreamer.h#L32 Here I can see the stream is sent to the linked client. The esp32-cam here is still acting as server. May be I need to write my own library that can send the stream to another server which is not a client for esp32 cam module.. Or is there any easy way to tweak it? – Ishaan Puniani Apr 01 '20 at 03:05
  • Seem that can use ESP32-CAM as RTSP-server(edge server) and then convert this protocol into RTMP. – Ion Stefanache Sep 08 '20 at 13:42
  • For ESP32-CAM RTSP server a good tutorial is https://learn.circuit.rocks/esp32-cam-with-rtsp-video-streaming and for conversion RTSP to RTMP can use one this tutorial https://flashphoner.com/how-to-broadcast-webrtc-rtsp-and-rtmp-streams-to-media-source-extensions-via-the-websocket-protocol/(in fact can use one webrtc server(=broker=proxy=intermediate like WebCallServer 5 from flashphoner) which accept rtsp as input and send real-time streaming to youtobe using RTMP) – Ion Stefanache Sep 08 '20 at 13:50