Skip to content

ron007d/fast_api_webrtc_streamer

Repository files navigation

FAST API FOR WEBRTC

A FAST API SINGALLING SERVER WITH AIORTC WEB STREAMER

Setup

  1. For signalling server install the signalling_server_req.txt using pip
pip3 install -r signalling_server_req.txt
  1. For camera_streamer install the camera_stream_req.txt using pip
pip3 install -r signalling_server_req.txt
  1. Change the server address for webcam_streamer.py

    a. Change the code - Hard code the address in the py file as server_url b. create .env file in the camera_code directory

HOST=xxx.xxx.xxx.xxx
PORT=xxxx
SERVER_URL=http://${HOST}:${PORT}/

How to run

  1. run router.py from signalling_server folder
python3 signalling_server/router.py
  1. in another system from where you want to stream video output run the camera_code
python3 camera_code/webcam_streamer.py

The implementation flows and learning flow works like this.

Implementation flow

  1. FAST API will work as a signalling server.

  2. Currently it will follow only request response model but in later time websocket or socket io will be implemented.

  3. There will be two user call and answer.

    a. Call will create username/room

    b. answer will check all the username/room list and select one and will try to connect to that.


Supporting features

  1. Added support python aiortc.
  2. video quality needed to be fixed on aiortc side.

workdone

Index Work Under Planning Under Progress Testing Completeds Comments
1 Create a simple page with two redirects call and answer
2 In the call page create a SDP (Session description) and send it to the fast api Sending to localhost:8080/offer_data as post request
3 Add Java script to get the answer response from another points Added java script which request from localhost:8080/get_answer/<username> if anyone answers from answer page then it will take it and connect with the client
4 create answer page where the offers will be shown and user can select those took the keys from the offers directionay and passed it to jinja compiler
5 Get the offer from the selected user and create answer SDP and pass it to the answer_data Done
6 Check the whole flow and test if it working text is being transmitted and ICE candidate is working 😊
7 Create a simple HTML page and transmit video using WEB RTC Created using miniwebrtc github and working
8 Test the video transmission in LAN LAN CONNECTION WORKING WITH VIDEO TRANSMISSION
9 Test the video in NAT transmission Done
10 Python AIORTC code to stream video from camera Done
10 Python AIORTC code to Get video stream from another source you can add other sources of the video also like video or a camera which is currently in your resident and streaming RTSP stream

Issues

  1. only Text mode is working in LAN and WAN where the ice candiadates are getting success but in video mode only LAN ice candidate is working.

    Issue resolved by adding turn ✅

  2. Added turn server but still its not working properly.

    Needed more testing to confirm the issue. ✅

Inspried by

https://github.com/xem/miniWebRTC https://github.com/aiortc/aiortc/tree/main/examples

👆 Check the aiortc example folder for more ways of implementation of webrtc in python

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published