Kurento combat II: rapid deployment and experience


Welcome to my GitHub


Content: a summary of all original articles and supporting source code, involving Java, docker, kubernetes, Devops, etc;

Overview of this article

  • This article is the second part of “kurento’s actual combat”. We manually deployed kms and experienced a demo. We have the most preliminary understanding of kurento. Now in retrospect, it seems that the operation is a little cumbersome. Today, let’s try to use docker to quickly deploy kms, and then quickly experience multiple official demos;
  • This chapter consists of the following contents:

Next, let’s start to experience;

Environmental preparation

  1. For this actual battle, you need to prepare a Linux computer, which can be physical machine or virtual machine, Ubuntu or CentOS. There are no special requirements for the version. I use centos-7.9 here;
  2. All operations in this article arerootaccount number;
  3. The next steps are environment preparation;
  4. Turn off the firewall and disable startup:
systemctl stop firewalld && systemctl disable firewalld
  1. Execute the following command to install WGet and docker:
yum install -y wget yum-utils device-mapper-persistent-data lvm2 \
&& yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo \
&& yum install  -y docker-ce docker-ce-cli containerd.io \
&& systemctl start docker
  1. implementdocker version, if you see the following information, it means that docker is successfully installed and started:
[[email protected] ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.2
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        2291f61
 Built:             Mon Dec 28 16:17:48 2020
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
  Version:          20.10.2
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8891c58
  Built:            Mon Dec 28 16:16:13 2020
  OS/Arch:          linux/amd64
  Experimental:     false
  Version:          1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
  Version:          0.19.0
  GitCommit:        de40ad0
  1. Set the image acceleration, otherwise the image download is slow and often times out. Execute the following command to complete the image acceleration setting and make it effective:
mkdir -p /etc/docker
tee /etc/docker/daemon.json <

Environment preparation is completed, and then KMS is installed;

Install KMS

  1. The KMS installation can be completed by executing the following commands. Downloading the image takes some time. Please wait patiently:
docker run -d \
--name kms \
--network host \
  1. Waiting for the console output to complete means that kms deployment and startup are completed. Check the container situation:
[[email protected] ~]# docker ps
CONTAINER ID   IMAGE                               COMMAND            CREATED         STATUS                   PORTS     NAMES
4265203b2baa   kurento/kurento-media-server:6.15   "/entrypoint.sh"   3 minutes ago   Up 3 minutes (healthy)             kms
  1. Execute the following command to confirm whether the response is normal:
curl -i -N \
    -H "Connection: Upgrade" \
    -H "Upgrade: websocket" \
    -H "Host:" \
    -H "Origin:" \
  1. If the console responds to the following contents, it proves that kms has been able to work normally:
HTTP/1.1 500 Internal Server Error
Server: WebSocket++/0.7.0
  1. Need extra attention: from the frontdocker runIt can be found from the parameters of the command that the KMS container directly uses the network card (–network host) of the host machine. Therefore,Please do not perform the operations in this article on the Mac, because the docker of the MAC does not support the host network mode
  • So far, KMS has been deployed (that is, one line of command). Next, try how to quickly experience multiple official demos;

About official demo

  1. Kurento officially implemented kms client based on Java and nodejs respectively, and implemented demo based on these two clients respectively;
  2. Please forgive Xinchen for her lack of achievements in the field of nodejs. Next, we will experience the demo of java version. The key isHow to quickly experience these demos
  3. The address of the Java version demo is:https://github.com/Kurento/kurento-tutorial-java, as shown in the following figure, it has rich functions:


Demo running environment preparation

  1. Since the demo is a java version, to install JDK and maven, the following are the installation steps;
  2. Please download the JDK installation package of linxu version. I usejdk-8u191-linux-x64.tar.gz, please go to Oracle official download by yourself;
  3. takejdk-8u191-linux-x64.tar.gzUpload it to CentOS computer, and then execute the following command to extract the JDK package to the appropriate location:
mkdir -p /usr/lib/jvm
tar -C /usr/lib/jvm/ -xzf jdk-8u191-linux-x64.tar.gz
  1. Write JDK related information in the environment variable and make it effective:
echo 'export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_191' >> ~/.bashrc
echo 'export JRE_HOME=${JAVA_HOME}/jre' >> ~/.bashrc
echo 'export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib' >> ~/.bashrc
echo 'export PATH=${JAVA_HOME}/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
  1. implementjava -versionCheck whether the settings have taken effect:
[[email protected] ~]# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
  1. Next, maven, execute the following commands to complete all the work of downloading, decompressing, and setting environment variables:
wget https://mirrors.bfsu.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
tar -C /usr/local/ -xzf apache-maven-3.6.3-bin.tar.gz
echo 'export MAVEN_HOME=/usr/local/apache-maven-3.6.3' >> ~/.bashrc
echo 'export PATH=$MAVEN_HOME/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
  1. implementmvn -versionCheck whether the settings have taken effect:
[[email protected] ~]# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/apache-maven-3.6.3
Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: /usr/lib/jvm/jdk1.8.0_191/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.11.1.el7.x86_64", arch: "amd64", family: "unix"
  1. In order to improve the download speed of the second-party library, it is recommended to configure the Alibaba cloud warehouse and open the file/usr/local/apache-maven-3.6.3/conf/settings.xml, foundmirrorsNode, add the following contents:
          Nexus aliyun
  1. Save and exit. The environment setting has been completed. Next, you can download the demo source code;

Download the official demo

  1. Now let’s download the official demo for later experience;
  2. In order to ensure the stability of the demo, the latest code is not downloaded, but archived6.15.0Version, execute the following commands to complete the download and decompression:
wget https://github.com/Kurento/kurento-tutorial-java/archive/6.15.0.tar.gz
tar -xzf 6.15.0.tar.gz
  1. After decompression, there is a folder named, which contains the demos in the previous screenshot:
[[email protected] ~]# tree -L 1 kurento-tutorial-java-6.15.0/
├── kurento-chroma
├── kurento-crowddetector
├── kurento-group-call
├── kurento-hello-world
├── kurento-hello-world-recording
├── kurento-hello-world-repository
├── kurento-magic-mirror
├── kurento-metadata-example
├── kurento-one2many-call
├── kurento-one2one-call
├── kurento-one2one-call-advanced
├── kurento-one2one-call-recording
├── kurento-platedetector
├── kurento-player
├── kurento-pointerdetector
├── kurento-rtp-receiver
├── kurento-send-data-channel
├── kurento-show-data-channel
├── pom.xml
└── README.md

18 directories, 4 files
  • So far, the preparations before running the official demo have been completed, and start to experience the wonderful official demo!

Before running the official demo, first sort out the data flow

  1. Take a brief look at the current situation. The current situation is shown in the following figure. KMS is running on centoos computer:


  1. Once we run a demo, it will look like the following figure:


  1. Then, we will use a browser to access the web page of the demo application on another computer tokurento-hello-worldTaking this demo as an example, the basic process is as follows (the complex process of webrtc is omitted):

4. The above is the data flow involved in the most basic demo. Of course, each demo has its own particularity. For example, the live demo connects multiple browsers to kms, but it is similar to the above flowchart on the whole;

  • After so much preparation, you may be angry that you haven’t started running the demo yet. Well, I won’t continue to force you. Let’s start running the demo immediately;
  • One more word: please prepare the camera and microphone on the computer running the browser, otherwise many demo functions cannot be experienced;

One of the demos: my local preview + real-time playback

  1. Enter the subdirectory of the demo source codekurento-hello-world, execute the following command to start the demo application, and transfer the console information to~/kurento-hello-world.log
nohup mvn -U clean spring-boot:run \
-Dspring-boot.run.jvmArguments="-Dkms.url=ws://localhost:8888/kurento" \
>> ~/kurento-hello-world.log \
2>&1 &
  1. Start compiling the project at this timekurento-hello-world, it will take some time to execute the commandtail -f ~/kurento-hello-world.logCheck the current progress, as shown below. I am still downloading the second-party library here:
Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/jcraft/jsch.agentproxy.jsch/0.0.9/jsch.agentproxy.jsch-0.0.9.jar (0 B at 0 B/s)
Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-6/plexus-interactivity-api-1.0-alpha-6.jar (0 B at 0 B/s)
Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/wagon/wagon-ssh-common/3.3.2/wagon-ssh-common-3.3.2.jar
Progress (1): 1.9 kB
  1. After a long wait, enter the following information, marking the successful start of the demo:
[INFO] --- spring-boot-maven-plugin:2.2.4.RELEASE:run (default-cli) @ kurento-hello-world ---
[INFO] Attaching agents: []

   |                                    |
   |   | |/ /  _ _ _ ___ _ _| |_ ___    |
   |   | ' < || | '_/ -_) ' \  _/ _ \   |
   |   |_|\_\_,_|_| \___|_||_\__\___/   |
   |                                    |
       Kurento Java Tutorial - Hello World
       Version 6.15.0

2021-01-09 15:56:15.348  WARN 35812 --- [           main] o.s.boot.StartupInfoLogger               : InetAddress.getLocalHost().getHostName() took 10012 milliseconds to respond. Please verify your network configuration.
2021-01-09 15:56:25.366  INFO 35812 --- [           main] o.k.tutorial.helloworld.Application      : Starting Application on centos7 with PID 35812 (/root/kurento-tutorial-java-6.15.0/kurento-hello-world/target/classes started by root in /root/kurento-tutorial-java-6.15.0/kurento-hello-world)
2021-01-09 15:56:25.367  INFO 35812 --- [           main] o.k.tutorial.helloworld.Application      : No active profile set, falling back to default profiles: default
2021-01-09 15:56:25.984  INFO 35812 --- [rbeatExec-e1-t0] o.k.j.c.JsonRpcClientNettyWebSocket      : [KurentoClient]  Connecting native client
2021-01-09 15:56:25.985  INFO 35812 --- [rbeatExec-e1-t0] o.k.j.c.JsonRpcClientNettyWebSocket      : [KurentoClient]  Creating new NioEventLoopGroup
2021-01-09 15:56:41.079  INFO 35812 --- [ntLoopGroup-2-1] o.k.j.c.JsonRpcClientNettyWebSocket      : [KurentoClient]  Initiating new Netty channel. Will create new handler too!
2021-01-09 15:56:41.140  WARN 35812 --- [           main] org.kurento.client.KurentoClient         : Connected to KMS in 15142 millis (> 5000 millis)
2021-01-09 15:56:41.704  INFO 35812 --- [           main] o.k.tutorial.helloworld.Application      : Started Application in 51.601 seconds (JVM running for 51.817)
  1. The IP address of my CentOS computer is192.168.133.208Therefore, the address of accessing the demo with the browser is:, you can experience the functions of the demo, as shown in the following figure:


  • Let this service run all the time. Next, let’s continue to experience the next demo;

Demo 2: my local preview + real-time playback (with filter effect)

  1. The demo to be experienced soon has the same function as the previous one. It also obtains local video data from kms for display. The difference is that kms will process the video and add a hat to the people in the video;
  2. Enter the subdirectory of the demo source codekurento-magic-mirror, there is a problem to be solved before starting this application: the previous demo has occupied port 8443, so it can’t be used here, and it needs to be changed;
  3. openkurento-magic-mirrorUnder the directorypom.xmlFile, find the position in the red box below. Here is the value of the application port. Please change it to an unoccupied value (I changed it here8444):

4. Execute the following commands to start the demo application and transfer the console information to~/kurento-magic-mirror.log

nohup mvn -U clean spring-boot:run \
-Dspring-boot.run.jvmArguments="-Dkms.url=ws://localhost:8888/kurento" \
>> ~/kurento-magic-mirror.log \
2>&1 &
  1. After successful startup, the browser accesseshttps://, the effect of running is shown in the figure below. The person in the video wears a hat:


Introduction to other typical demos

  • Due to space limitations, other demos will not be operated one by one. You have mastered all the key points and can start and experience by yourself. Here are a few typical demos briefly introduced, hoping to bring some references to your experience:
  1. Kurento One2One call: in one-on-one video chat, Zhang San enters his name in “name”, then clicks “register”, Li Si enters his name in “name”, then enters Zhang San’s name in “peer”, and then clicks “call” to initiate a chat
  2. Kurento One2many call: live broadcast, the anchor clicks “presenter” to start the live broadcast, and the audience clicks “viewer” to watch the live broadcast (in the demo environment, only one anchor is supported)
  3. Kurento group call: multi person meeting, enter your name, and then enter the room name to start the multi person meeting
  4. Kurento platedetector: recognize the license plate through the camera (it’s difficult to recognize, it’s not easy to recognize, and it’s also wrong to recognize)
  5. Kurento chroma: it will replace the green area in the video with the picture of Super Mario
  6. Kurento crowddetector: delimit an area (ROI) in the video. If there is a crowd in the area, it will flash
  7. Kurento player: specify the streaming media address, pull and decode by kms, and then deliver it to the browser in real time through webrtc
  8. Kurento pointerdetector: in several fixed areas, if objects of some colors shake in these positions (some colors refer to the colors that can be recognized by the designated filter of KMS), the console of the page will output the events of these objects entering and exiting the area
  • The above is the detailed steps of quickly deploying kms and experiencing the official demo. I hope this article can help you quickly understand kurento. In the next article, we will gradually learn more about kurento development.

You’re not alone, Xinchen original accompanies you all the way

  1. Java series
  2. Spring series
  3. Docker series
  4. Kubernetes series
  5. Database + middleware series
  6. Devops series

Welcome to official account: programmer Xinchen

Wechat search “programmer Xinchen”, I’m Xinchen, looking forward to traveling with you in the Java World

Recommended Today

JS generate guid method

JS generate guid method https://blog.csdn.net/Alive_tree/article/details/87942348 Globally unique identification(GUID) is an algorithm generatedBinaryCount Reg128 bitsNumber ofidentifier , GUID is mainly used in networks or systems with multiple nodes and computers. Ideally, any computational geometry computer cluster will not generate two identical guids, and the total number of guids is2^128In theory, it is difficult to make two […]