Stream esp-32 camera to RTMP server like YouTube

只谈情不闲聊 提交于 2020-04-18 05:44:55

问题


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}

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

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

**

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


回答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)



来源:https://stackoverflow.com/questions/60908201/stream-esp-32-camera-to-rtmp-server-like-youtube

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!