Welcome to my GitHub
https://github.com/zq2599/blog_demos
Content: Classification and 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 Actual Combat". In the previous article, we manually deployed KMS and experienced a demo. We have the most preliminary understanding of Kurento. Now it seems that the operation is a bit cumbersome. Today, let’s try to use docker to quickly deploy KMS. Quickly experience multiple official demos;
- This article consists of the following contents:
Let’s start the experience next;
Environmental preparation
- For this actual combat, you need to prepare a Linux computer, both physical and virtual machines, Ubuntu or CentOS, and there are no special requirements for the version. I use CentOS-7.9 here;
- All operations in this article use the <font color="red">root</font> account;
- Next are the steps of environment preparation;
- Turn off the firewall and prohibit startup:
systemctl stop firewalld && systemctl disable firewalld
- Execute the following commands 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
- Execute <font color="red">docker version</font>, if you see the following information, it means that docker is installed and started successfully:
[root@centos7 ~]# 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
Engine:
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
containerd:
Version: 1.4.3
GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b
runc:
Version: 1.0.0-rc92
GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
docker-init:
Version: 0.19.0
GitCommit: de40ad0
- Set the mirror acceleration, otherwise download the mirror slowly and often time out, execute the following command to complete the mirror acceleration setting and make it effective:
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
The environment preparation is complete, then install KMS;
Install KMS
- Execute the following command to complete the KMS installation, downloading the image is time-consuming, please be patient:
docker run -d \
--name kms \
--network host \
kurento/kurento-media-server:6.15
- Waiting for the completion of the console output means that the KMS deployment and startup are completed. Check the container status:
[root@centos7 ~]# 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
- Execute the following command to confirm whether the response is normal:
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
- If the console responds with the following content, it proves that KMS can already serve normally:
HTTP/1.1 500 Internal Server Error
Server: WebSocket++/0.7.0
- <font color="red">Special attention is required</font>: From the parameters of the previous <font color="blue">docker run</font> command, it can be found that the KMS container directly uses the host's network card (- -network host), therefore, <font color="red">please do not perform the operations in this article on a Mac computer, because the docker of a Mac computer does not support the host network mode</font>;
- At this point, the KMS deployment is completed (that is, one line of command), let's try how to quickly experience multiple official demos;
About the official demo
- Kurento officially implemented KMS clients based on java and nodejs, and implemented demos based on these two clients;
- Please forgive Xinchen for no achievements in the field of nodejs. Next, we will experience the java version of the demo. The focus is on <font color="blue">how to quickly experience these demos</font>;
- The address of the java version demo is: https://github.com/Kurento/kurento-tutorial-java , as shown in the figure below, the function is very rich:
Demo operating environment preparation
- Since the demo is a java version, you need to install JDK and Maven. Here are the installation steps;
- Please download the Linxu version of the JDK installation package, I used <font color="blue">jdk-8u191-linux-x64.tar.gz</font> here, please go to the official Oracle download;
- Upload <font color="blue">jdk-8u191-linux-x64.tar.gz</font> to the CentOS computer, and then execute the following command to extract the JDK package to a suitable location:
mkdir -p /usr/lib/jvm
tar -C /usr/lib/jvm/ -xzf jdk-8u191-linux-x64.tar.gz
- 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
- Execute <font color="blue">java -version</font> to see if the setting has taken effect:
[root@centos7 ~]# 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)
- Next is maven, execute the following commands to complete all tasks such as 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
- Execute <font color="blue">mvn -version</font> to see if the setting has taken effect:
[root@centos7 ~]# 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"
- In order to improve the download speed of the second party library, it is recommended to configure the Alibaba Cloud warehouse, open the file <font color="blue">/usr/local/apache-maven-3.6.3/conf/settings.xml</font> and find the <font color="blue">/usr/local/apache-maven-3.6.3/conf/settings.xml</font> font color="red">mirrors</font> node, add the following content inside:
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
- Save and exit, the environment settings have been completed, and then you can download the demo source code;
Download the official demo
- Now let's download the official demo for later experience;
- In order to ensure the stability of the demo, the latest code is not downloaded, but the archived version of <font color="blue">6.15.0</font>, execute the following command 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
- After decompression, it is a folder named, which contains the demos in the previous screenshot:
[root@centos7 ~]# tree -L 1 kurento-tutorial-java-6.15.0/
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
├── LICENSE
├── NOTICE
├── pom.xml
└── README.md
18 directories, 4 files
- At this point, the preparatory work before running the official demo has been completed, start experiencing the wonderful official demo!
Before running the official demo, sort out the data flow
- Take a brief look at the current situation. The current situation is shown in the following figure. KMS is running on the CentoOS computer:
- Once we run a demo, it will look like the following picture:
- Then, we will use a browser on another computer to access the webpage of the demo application. Take the demo of <font color="blue">kurento-hello-world</font> as an example. The basic process is as follows (WebRTC is omitted) Complex process):
- The above is the data flow involved in a most basic demo. Of course, each demo has its own characteristics. For example, the live demo is connected to KMS by multiple browsers, but the overall flow is similar to the above flowchart;
- After doing so much preparation work, you have not started to run the demo. Maybe you are already very angry. Okay, I won't continue to force it. Let's start running the demo immediately;
- One more sentence: Please prepare a camera and microphone on the computer running the browser, otherwise many demo functions cannot be experienced;
One of the demos: local preview + real-time playback
- Enter the subdirectory of the demo source code <font color="blue">kurento-hello-world</font>, execute the following command to start the demo application, and save the console information to <font color="blue"> ~/kurento-hello-world.log</font>:
nohup mvn -U clean spring-boot:run \
-Dspring-boot.run.jvmArguments="-Dkms.url=ws://localhost:8888/kurento" \
>> ~/kurento-hello-world.log \
2>&1 &
- At this point, start to compile the project <font color="blue">kurento-hello-world</font>. It will take a certain amount of time. You can execute the command <font color="blue">tail -f ~/kurento-hello-world. log</font> to view 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
...
- After a long wait, enter the following information, which marks the successful launch 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)
- The IP of my CentOS computer here is <font color="blue">192.168.133.208</font>, so the address for accessing the demo with a browser is: https://192.168.133.208:8443/ , you can experience the demo Function, as shown below:
- Let this service keep running, let's continue to experience the next demo;
Demo 2: My local preview + real-time playback (with filter effects)
- The demo to be experienced soon has the same function as the previous ones. 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 person in the video;
- Enter the subdirectory of the demo source code <font color="blue">kurento-magic-mirror</font>, there is a problem to deal with before starting this application: the previous demo has already occupied port 8443, so it can’t be used here anymore. , To change;
- Open the <font color="red">pom.xml</font> file in the <font color="blue">kurento-magic-mirror</font> directory, and find the position of the red box in the figure below, here is the application port Value, please change it to an unoccupied value (I changed it to <font color="blue">8444</font>):
- Execute the following command to start the demo application, and dump the console information to <font color="blue">~/kurento-magic-mirror.log</font>:
nohup mvn -U clean spring-boot:run \
-Dspring-boot.run.jvmArguments="-Dkms.url=ws://localhost:8888/kurento" \
>> ~/kurento-magic-mirror.log \
2>&1 &
- After the startup is successful, the browser visits <font color="blue"> https://192.168.133.208:8444/ </font>, the effect of running is as shown in the figure below, the person in the video brought a top hat:
Introduction to other typical demos
- Due to space limitations, other demos will no longer be operated one by one. You have mastered all the points and can start and experience by yourself. Here is a brief introduction to a few typical demos, hoping to bring some references to your experience:
- kurento-one2one-call: One-to-one video chat, Zhang San enters his name in "Name", then clicks "Register", Li Si enters his name in "Name", and then enters Zhang San's name in "Peer" and then click "Call" to start a chat
- kurento-one2many-call: live broadcast, the host clicks "Presenter" to start the live broadcast, the audience clicks "Viewer" to watch the live broadcast (the presentation environment, only supports one host)
- kurento-group-call: Multi-person conference, enter your name, and then enter the room name to start a multi-person conference
- kurento-platedetector: Recognize the license plate through the camera (difficult to recognize, finally recognized, and recognition error)
- kurento-chroma: replace the green area in the video with a picture of Super Mario
- kurento-crowddetector: delimit a region (ROI) in the video, if there is a crowd in the region, it will flash
- kurento-player: Specify the streaming media address, KMS pulls it and decodes it, and then delivers it to the browser in real time via WebRTC
- kurento-pointerdetector: In several fixed areas, if objects of certain colors shake in these locations (some colors refer to colors that can be recognized by the designated filter of KMS), the console of the page will output these objects to enter and Event of exit area
- The above is the detailed steps to quickly deploy KMS and experience the official demo. I hope this article can help you quickly understand Kurento. In the next article, we will gradually learn about Kurento development.
You are not alone, Xinchen and original are with you all the way
- Java series
- Spring series
- Docker series
- kubernetes series
- database + middleware series
- DevOps series
Welcome to pay attention to the public account: programmer Xin Chen
Search "Programmer Xin Chen" on WeChat, I am Xin Chen, and I look forward to traveling the Java world with you...
https://github.com/zq2599/blog_demos
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。