preface
Some time ago to do RTSP no plug-in web end play inadvertently came into contact with a media server called Kurento, simply speaking, Kurento is a WebRTC media server, at the same time provides a series of client API, can simplify for browser, mobile platform for the use of video application development. Today I will share with you what WebRTC is and what WebRTC does by contacting Kurentu.
About the WebRTC
WebRTC, short for Web Real-time Communication, is an API that enables Web browsers to conduct real-time voice or video conversations. It became open source on June 1, 2011 and was incorporated into the World Wide Web Consortium’s W3C recommendation with support from Google, Mozilla, and Opera.
The ultimate goal of WebRTC (Web Real-time Communication) project is to enable Web developers to use browsers (Chrome\FireFox…). Web developers also do not need to pay attention to the digital signal processing process of multimedia. They only need to write simple Javascript programs to achieve it. Organizations such as W3C are formulating Javascript standard APIS. It is WebRTC 1.0 and in Draft state. In addition, WebRTC also hopes to build a robust real-time communication platform between multiple Internet browsers, forming a good ecological environment for developers and browser manufacturers. At the same time, Google also hopes and is committed to make WebRTC technology as one of the HTML5 standards, which shows the far-reaching layout of Google.
WebRTC provides the core technology of video conference, including audio and video collection, encoding and decoding, network transmission, display and other functions, and supports cross-platform: Windows, Linux, MAC and Android.
About Kurento
Kurento is a WebRTC media server and a set of client apis that simplify the development of advanced video applications for the Web and smartphone platforms. Its features include audio-visual streams for group communication, code conversion, recording, blending, broadcasting and routing.
Kurento provides a multimedia framework with the following features to simplify the task of building multimedia applications:
- Dynamic WebRTC Media Pipes: Kurento allows custom media pipes to connect to WebRTC peers, such as Web browsers and mobile applications. These media pipes are based on composable elements such as players, loggers, and mixers that can be mixed and matched, activated or deactivated at any point in time, even if the media is already in circulation.
- Client/server architecture: Applications developed using Kurento follow client/server architecture. The Kurento Media Server (KMS) is the server and provides a WebSocket interface that implements the Kurento protocol, which allows client applications to define pipe topologies.
- Java and JavaScript client applications: A typical use case for A KMS deployment consists of a three-tier architecture in which the user’s browser interacts with the KMS server through an intermediate client application. There are several official Kurento client libraries that support the use of Java and JavaScript in client applications. Following the WebSocket protocol, it is easy to implement clients in other languages.
- Third party modules: Kurento media server has a plug-in based extensible architecture that allows third parties to implement modules that can be added to their media pipeline. This allows media processing algorithms to be integrated into any WebRTC application, such as integrated computer vision, augmented reality, video indexing and voice analysis. All you need to do is create a new Kurento element and apply it to any existing media pipes
Local installation of Kurento
Understanding the basic concept, we don’t say much more direct installation
1. Ensure that GnuPG has been installed
`sudo apt-get update && sudo apt-get install --no-install-recommends --yes \
gnupg`
Copy the code
2. Define which version of Ubuntu is installed on your system and run only one of the following lines
# Run ONLY ONE of these lines:
DISTRO="xenial" # KMS for Ubuntu 16.04 (Xenial)
DISTRO="bionic" # KMS for Ubuntu 18.04 (Bionic)
Copy the code
3. Add the Kurento repository to your system configuration
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5AFA7A83
sudo tee "/etc/apt/sources.list.d/kurento.list" >/dev/null <<EOF# Kurento Media Server - Release packagesDeb [arch = amd64] http://ubuntu.openvidu.io/6.13.0$DISTRO kms6
EOF
Copy the code
4. Install KMS:
sudo apt-get update && sudo apt-get install --yes kurento-media-server
5. KMS command
Sudo service kurento-media-server start
Sudo service kurento-media-server stop
Docker deployment
KMS is only available on Ubuntu, and only version 16.04 was successful when I installed it, which may be related to my VIRTUAL machine. Fortunately, docker version is available on the official website, which is really delicious! Docker specific usage of baidu
1. The Docker Pull command
docker pull kurento/kurento-media-server
Copy the code
docker run --name kms -d -p 8888:8888 \
kurento/kurento-media-server
Copy the code
3. Check whether KMS succeeds
To check that KMS is ready and listening, issue the following command (you need curl to install on your system) :
curl -i -N \
-H "Connection: Upgrade" \
-H "Upgrade: websocket" \
-H Host: 127.0.0.1: "8888" \
-H "Origin: 127.0.0.1" \
http://127.0.0.1:8888/kurento
Copy the code
Your KMS media server is successfully installed and running if you get the following response:
HTTP/1.1 500 Internal Server Error Server: WebSocket++/0.7.0
4.KMS log tracking
docker logs --follow kms
Copy the code
International practice: Hello World
How to deploy
The kurento server language provides node and Java as a front end. We would definitely prefer Node, but Java has a lot more functionality than Node. You can choose according to your skill stack. Start by installing Node and Git on your computer or virtual machine.
Here’s the routine:
git clone https://github.com/Kurento/kurento-tutorial-node.git
cd kurento-tutorial-node/kurento-hello-world
npm install
npm start
Copy the code
Ok, so if you’re not surprised, you’re already running. First example
Results show
One to one video call
The base is held
cd kurento-tutorial-node/kurento-one2one-call
npm install
npm start
Copy the code
Results show
My two terminals, the MAC and my phone
Here I want to emphasize that the browser running on the mobile terminal needs to give relevant permissions otherwise it cannot be used
mac
After registration, the MAC user calls the phone
Press OK to have a fun video call!
1 to many broadcasting: Anchor mode
The base is held
cd kurento-one2many-call
npm install
npm start
Copy the code
Results show
Mobile live computer view, if you are interested in Kurento also has filters and video streaming module you can add your favorite special effects
RTSP video stream Easter eggs
If you think that’s all Kurento has to offer, you’re wrong. Kurento offers a lot of extensions to webRTC, but I’m not going to cover them all because of the cable and Node language limitations. Github.com/lulop-k/kur…
There are also two plugins that you need to install
npm install -g bower
npm install -g live-server
Copy the code
The base is held
git clone https://github.com/Kurento/kurento-tutorial-node.git
cd kurento-rtsp2webrtc
bower install
live-server
Copy the code
Vscode will automatically jump to the page and enter the RTSP address to play (hikang NVR is used here, students who have related equipment can try).
Results show
Results the measured
- Just setting up a Kurento media server is much less costly to the server than the last two tutorials.
- Latency: Basically no latency, and audio and picture synchronization (depending on the network environment) is an intuitive improvement over RTMP and JSMPEG solutions
- It takes 2-3 seconds from the beginning of playback to the display of the picture
- Multi-channel video playback, I have common sense multi-channel video playback, there is no problem for the first time, but after the end of the run will be a screen, here may need to Java or KSM server customization, at this time as a front-end is very awkward, back-end language lack, I do not know where to start.
Write in the last
In general, Kurento open source free, many modules, as long as the ability is enough you can a variety of applications, but today’s introduction is limited to the use of LAN, if you want to use in the public network, but also to learn network penetration hole, server deployment ability, traffic consumption and so on, In the latest version of Chrome, HTTP does not have the permission to use the camera. If you use HTTPS, you have to consider the certificate issue. I hope we can learn and make progress together in 2020. Finally, I wish you a happy New Year and double happy year-end bonus!