Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create video and voice call to python application?

I want to add video and voice call to my web application developed with python. I searched about it on internet, I found that I can do it with WebRTC, but this work is done with JavaScript, but I don't know how to do this work with python? I'm using Sanic as a web framework in python 3.6.

On the other hand, is it possible to do this work with socketio in python? I know this module is suitable for chatting apps. I appreciate for your help.

like image 660
Ali Najafi Avatar asked Mar 10 '18 06:03

Ali Najafi


2 Answers

There are several aspects involved in building WebRTC application:

  • Serving the web pages and javascript code used by your web clients. You can either use plain static files, or a server-side framework of your choice.

  • Providing a signaling channel which allows participants to exchange information about what media they support (audio, video, data channels) and how they can reach each other. Very often a WebSocket is used for this, but it's not the only possibility.

  • Taking part in the actual WebRTC media exchange. This really depends on your usecase. If you are doing one-to-one audio/video then the WebRTC endpoints are usually web browsers, but they could also be native applications. If you are building something like a voice-over-IP service, then most likely one endpoint is a browser, and the other is a server such as Asterisk or FreeSWITCH.

In the event you actually want your users to communicate with a custom server written in Python (for instance if you are doing audio / video processing using OpenCV) you can take a look at aiortc:

https://github.com/jlaine/aiortc

like image 158
Jeremy Avatar answered Oct 09 '22 13:10

Jeremy


Sanic is just a web server which will serve HTML and JavaScript. You could also use any web server and it would not matter to WebRTC. Web server has no interaction with WebRTC code in any way.

All WebRTC code that you need for video chat will be in a JavaScript file and that code will be used by your browser (Firefox, Chrome, Opera,...). What you need to do in a server is signaling between peers. For this signaling process you can use socketio in python.

I would recommend you to learn more about WebRTC https://codelabs.developers.google.com/codelabs/webrtc-web/#0

like image 2
Velexior Avatar answered Oct 09 '22 11:10

Velexior