webrtc without a browser - python

Right now I am using this project here. It is a python script that runs a server using webrtc to send the clients/browsers webcam to the server and perform face recognition. What I want to do is do the same thing with a web cam or pi cam hooked up to the pi but without the use of the browser. Is there a way to do it with the current set up or is there a better method to accomplish this?

You can use the native library and connect it to the face recognition server. You can use either the google implementation of webrtc or a more recent implementation (by Ericsson) called openWebrtc. The developers of openWebRTC are very proud of running their implementation on various pieces of hardware like raspberry pi and iOS devices.
If you don't what to mess with a native library you can use a nodejs binding for webrtc (for example node-webrtc or easyrtc)

If you want a Python implementation of WebRTC, give aiortc a try. It features support for audio, video and data channels and builds upon Python's asyncio framework.
The server example illustrates both how to perform image processing on a video stream and how to send video back to the remote party. Aside from signaling there is no actual "server" or "client" role in WebRTC so you can also run aiortc on your raspberry pi and have it send video frames to whatever WebRTC endpoint you want.

Related

How to stream multiple ESP32-CAM's to a Python Server and serve stream to clients over the cloud

I am developing a live monitoring application using multiple resources. The server is a Python Flask Application (Running on GCP using a docker container in cloud run). For the database for storing users, we chose Firestore, and authentication is done using JWT. The client application was created with React Native and receives information from the server using basic HTTP methods in a JSON format.
As for now, the whole system works, but it is still missing the live cameras. I never played around with live video streaming or anything like that.
For hardware, we chose ESP32-CAM modules as they are cheap and easy to maintain.
The problem is that I have no idea how to stream the camera content to the server and serve that to the client. Remember that the cameras would be at various locations with no external IP access, so the server couldn't just make capture requests for the camera; the camera themselves will have to send the information to the server.
I took a look at some ESP32-CAM libraries and various communications methods, but none fit what I am trying to do or that have enough documentation for a basic understanding. Some were RTSP, FFmpeg, Sockets, HLS, WebRCT. It must be compatible with the ESP32 (C++ or/and Arduino libraries) and Python packages. (With ports allowed to be accessed by GCP if needed)
Lastly, I would like suggestions on how and what to use to transmit the data to the final client.
Below is a quick schematic for the current infrastructure.
Schematic

Streaming live audio from audio interface over a local network via browser

This is my first post so sorry if it’s worded wrong/ put in the wrong place.
I am currently designing a prototype product which has the ability to take an audio input (for example the master channel from a sound desk) through an audio interface, and then place it on a browser-based application for all devices on the local network to access, listen to and download.
Currently I believe the best way to do this would be via WebRTC hosted on a server, such as a Raspberry Pi or equivalent, where WebRTC is ran through Python Tornado/Flask in order to serve this to an HTTP page. I would like some advice on the best way to do this, or if you believe if there is a more efficient way to do this?
I was going to use the server to also act as a DHCP server as it will be for local environments only. Management features such as routing protocols, logging/debugging information and encryption handlers will also be displayed on this HTTP application.
I have attached a diagram of the topology that I am using, if I have not explained myself clearly.
Thanks.
Network Topology Image

Stream video frames from a Pi in real time

I am currently dealing with a Pi camera on a Raspberry Pi 2B. I would like to stream input images (which I am continuously collecting when turned on) in real-time to a server that runs computer vision software. The processing on my server then returns data based on the image recognition that has to be sent back to the Raspberry Pi.
Since the Raspberry Pi's video capturing and WiFi capabilities might not be too overwhelming, I think about the best way to stream such data, both images/video frames from the Pi and (maybe) JSON-formatted table-like generated data in the opposite direction.
I thought about the following possibilities which I want to implement in Python (easier) or C++ (faster if necessary):
Frames
entire frame in REST API, accessible through GET
streaming via TCP
pushing and pulling from a SQL database on the server
Generated data
pushing and pulling from a SQL database on the server
pushing and pulling from a Redis database on the server
REST API on server, collecting via GET on the Pi
There are definitely other possibilities which I might not know yet. So you're welcome to recommend your favourite solution. I am really looking forward to hear about the pros and cons of each technology.
Thanks!

python rtsp to webrtc

I want to pass an h.264 or MJPEG RTSP stream from an IP camera directly to a webRTC session in a browser, without re-encoding. It has to be done in python, because the target is to have such RTSP/WebRTC gateway reside on the camera itself, which has a python interpreter. The stream is one way, to the browser only. I'm a python freshman, so any hints, ideas, or links to existing libraries are welcome.
I've seen the writeup at http://www.codeproject.com/Articles/800910/Broadcasting-of-a-Video-Stream-from-an-IP-camera-U, but this requires transcode to VP8 (and is not python).
Also reviewed the thread at Use an IP-camera with webRTC and looked at the Kurento media server (nodejs) and Janus gateway (C).
One of the commenters said "you could probably very easily use the native webrtc API and provide an RTSP stream through it." Do there exist any python bindings to the native WebRTC api? Am I deranged for even thinking such a gateway application is possible in python?
Firefox supports H.264 (via the OpenH264 plugin, which is automatically downloaded). Chrome will be adding H.264 "soon". Neither supports MJPEG, nor does the native webrtc.org code - though MJPEG is supported by all of them as a camera-capture source, and it wouldn't be particularly hard to add an MJPEG video codec to the native webrtc.org code. (Non-trivial, however, because of the number of things you'd need to change.)
Note that if this traverses the open internet (or even potentially a wifi link) your solution will be unable to easily adapt to bitrate changes without asking the IP camera to change it's rate.

Python livestream to RTMP server (Flash Media Server clone?)

I would like to play around with coding an application that could capture a desktop or section of a screen (height and width variables for resolution) and stream those to an RTMP server (rtmp://server.com/live).
I saw something called rtmplite, but the description of this package is:
"This is a python implementation of the Flash RTMP server"
So I would ultimately like to achieve the following, but will implement it in pieces as I go along, without getting overwhelmed at the project scope:
Make connection to RTMP server (with authentication where needed) to channel on ustream.com, justin.tv/twitch.tv, own3d.tv, etc.
Ability to select height, width selection of desktop or entire desktop and stream live to that channel, as if I was using Flash Media Live Encoder.
Really I just want to make my own Python-based FMLE or Xsplit application so I can stream live on my own without using those applications.
Any libraries you can send me to read up on that explain this FMLE-clone type process or information would be helpful! Thanks
I did some RTMP streaming from python for the wiidiaplayer project: http://wiidiaplayer.org. This is by no means a full solution, but at least some RTMP functionality has been implemented in python there.
Unfortunately it has been a long time since I touched that code; if you have any questions feel free to ask them; I'm not sure how much of the answers I will be able to provide.

Categories

Resources