Welcome to my GitHub
Github.com/zq2599/blog…
Content: all original article classification summary and supporting source code, involving Java, Docker, Kubernetes, DevOPS, etc.;
This paper gives an overview of
- This article is the second part of “Kurento actual combat”. The previous part manually deployed KMS and experienced a demo. We have the most preliminary understanding of Kurento.
- This article is composed of the following contents:
Let’s get started;
Environment to prepare
- This time, you need to prepare a Linux computer, physical machine, virtual machine, Ubuntu or CentOS can be, version no special requirements, I use centos-7.9;
- All operations in this article use the root account;
- Next are a few steps to prepare the environment;
- Close the firewall and forbid startup:
systemctl stop firewalld && systemctl disable firewalld
Copy the code
- Run 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
Copy the code
- Run the Docker version command. If the following information is displayed, the Docker is successfully installed and started:
[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: 269548 fa27e0089a8b8278fc4fc781d7f65a939b runc: Version: 1.0.0 - rc92 GitCommit: Ff819c7e9184c13b7c2607fe6c30ae19403a7aff docker - init: Version: 0.19.0 GitCommit: de40ad0Copy the code
- Otherwise, the image download takes a long time and often times out. Run the following command to set the image acceleration to take effect:
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
Copy the code
Now that the environment is ready, install KMS.
Install the KMS
- Run the following command to complete the KMS installation:
Docker run -d --name KMS --network host kurento/kurento-media-server:6.15Copy the code
- Wait for console output to complete, which means KMS deployment and startup is complete, and check the container:
[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) KMSCopy the code
- Run the following command to check 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 \ "at http://127.0.0.1:8888/kurentoCopy the code
- KMS is ready to service if the console responds with the following:
HTTP/1.1 500 Internal Server Error
Server: WebSocket++/0.7.0
Copy the code
- Note: as can be seen from the previous docker run command parameters, KMS container directly uses the host’s network card (–network host), therefore, please do not execute this operation on the Mac, because the Mac docker does not support host network mode;
- Now that KMS is deployed (a one-line command), let’s try out how to play multiple official demos quickly;
About official Demo
- Kurento officially implemented KMS client based on Java and NodeJS respectively, and implemented Demo based on these two clients respectively;
- Forgive Chen for his lack of expertise in nodeJS, but let’s take a look at the Java version of the demo, focusing on how to experience them quickly;
- The address of the Java demo is github.com/Kurento/kur… , as shown in the picture below, the functions are very rich:
Demo running environment
- Since demo is a Java version, you need to install JDK and Maven. Here are the installation steps.
- Please download the JDK installation package of Linxu version, I used jdK-8U191-linux-x64.tar. gz, please go to the official Oracle to download;
- Run the following command to decompress the JDK package to an appropriate location:
mkdir -p /usr/lib/jvm
tar -C /usr/lib/jvm/ -xzf jdk-8u191-linux-x64.tar.gz
Copy the code
- Write JDK related information to 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' >> ~/ 'export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib' >> ~/.bashrc echo 'export PATH=${JAVA_HOME}/bin:$PATH' >> ~/.bashrc source ~/.bashrcCopy the code
- Run Java -version 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)
Copy the code
- For maven, run the following command to download, decompress, and set environment variables:
Wget tar - https://mirrors.bfsu.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz/usr/local/C -xzf apache-maven-3.6.3-bin.tar.gz echo 'export MAVEN_HOME=/usr/local/ apache-3.6.3 '>> ~/. Bashrc echo 'export PATH=$MAVEN_HOME/bin:$PATH' >> ~/.bashrc source ~/.bashrcCopy the code
- Run MVN -version to see if the setting takes 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"Copy the code
- To improve the download speed of the alicloud repository, open the /usr/local/apache-maven-3.6.3/conf/settings. XML file, find the mirrors node, and add the following information:
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
Copy the code
- Save and exit, environment setup is complete, next you can download the demo source;
Download official demo
- Now let’s download the official demo for later experience;
- To ensure the stability of the demo, instead of downloading the latest code, we will download the archived version 6.15.0. Run the following command to complete the download and decompress:
Wget https://github.com/Kurento/kurento-tutorial-java/archive/6.15.0.tar.gz tar - XZF 6.15.0. Tar. GzCopy the code
- Unzip it to a folder named “Demo” that contains the demo from the previous screenshot:
[root@centos7 ~]# School flag - # school Flag - # school Flag - # School Flag - # School Flag - # School Flag - # School Flag - # School Flag - # School Flag - # School Flag - # School Flag - # School Flag Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ Heavy Metal Guitar School ─ ├─ Kurento-Hello-World-Repository ├─ Kurento-Magic-Mirror Flag ─ Kurento-Metadata-Example Flag ─ 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. The XML └ ─ ─ the README. Md 18 directories, 4 filesCopy the code
- At this point, the preparation work before running the official demo is complete, start to experience the wonderful official demo!
Before running the official demo, take a look at the data flow
- To take a quick look at the current situation, the current situation is shown below, with KMS running on the CentoOS computer:
- Once we run a demo, it should look like this:
- Then, we will use a browser on another computer to access the web page of the demo application. Using kurento-hello-world as an example, the basic process is as follows (omitting the complex process of WebRTC) :
4. The above is a basic demo involved in the flow of data, of course, each demo has its own special, for example, live demo is multiple browsers connected to KMS, but overall similar to the above flow chart;
- You may be angry that you haven’t started running the demo yet after all this preparation work. Ok, I’m not going to continue pushing, let’s start running the demo immediately;
- One more word: please have a camera and microphone on the computer running the browser, otherwise many demo functions will not be able to experience;
Demo 1: my local preview + real-time playback
- Go to the kurento-hello-world subdirectory of demo source code, run the following command to start demo application, and save 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 &
Copy the code
- Kurento-hello-world: kurento-hello-world: kurento-hello-world: kurento-hello-world: kurento-hello-world: kurento-hello-world: kurento-hello-world: kurento-hello-world: kurento-hello-world: kurento-hello-world: kurento-hello-world: kurento-hello-world: kurento-hello-world: kurento-hello-world: kurento-hello-world
. 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-inte Ractivity-api-1.0-alpha-6.jar (0 B at 0 B/s) Downloading from Nexus - Aliyun: Downloading from Ractivity-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.6KB...Copy the code
- After a long wait, enter the following information to indicate that demo is successfully started:
[INFO] -- Spring-boot-Maven-plugin: 2.2.3. RELEASE:run (default-cli) @kurento-hello-world -- [INFO] select the Attaching agent for the Attaching team. []. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - | | | | | / / _ _ _ _ _ _ | | _ ___ | | | '< | | |' _ / _) \ _ / _ \ | | |_|\_\_,_|_| \___|_||_\__\___/ | | | '------------------------------------' Kurento Java Tutorial - Hello World Version 6.15.0 15:56:15 2021-01-09. 348 WARN 35812 - [the main] O.S.B oot. StartupInfoLogger: InetAddress.getLocalHost().getHostName() took 10012 milliseconds to respond. Please verify your network configuration. The 2021-01-09 15:56:25. 35812-366 the INFO [main] O.K.T utorial. The helloworld. Application: Starting Application on Centos7 with PID 35812 (/root/kurento-tutorial-java-6.15.0/ kurento-helo-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: The default 15:56:25 2021-01-09. 35812-984 the INFO/rbeatExec - e1 - t0 O.K.J.C.J sonRpcClientNettyWebSocket: [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! The 2021-01-09 15:56:41. 140 WARN 35812 - [the 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.T utorial. The helloworld. Application: Started Application in 51.601 seconds (JVM running for 51.817)Copy the code
- I here CentOS computer IP is 192.168.133.208, so use the browser to access the demo address is: https://192.168.133.208:8443/, you can experience the demo function, the following figure:
- Let’s just leave this service running and move on to the next demo;
Demo 2: My local preview + live playback (with filter effects)
- The demo we are about to experience has the same function as the previous one. It is also used to obtain 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.
- Kurento-magic-mirror = kurento-magic-mirror = kurento-magic-mirror = kurento-magic-mirror = Kurento-magic-mirror = Kurento-magic-mirror = Kurento-magic-mirror = Kurento-magic-mirror = Kurento-magic-mirror = Kurento-magic-mirror
- Open the pm. XML file in kurento-magic-mirror and find the red box below. Here is the value of the application port.
4. Run the following command to start demo and save 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 &
Copy the code
- Start after the success, the browser to https://192.168.133.208:8444/, the effect of the running as shown in the figure below, people wear a hat in the video:
Other typical Demo introduction
- Due to space constraints, other demos will not be done one by one. You have mastered all the key points and can start and play with them on your own. Here are a few more typical demos to give you some reference for your experience:
- Kurento-one2one-call: one-to-one video chat. John enters his Name in “Name” and then clicks “Register”. John enters his Name in “Name” and then clicks “Call” in “Peer” to initiate a video chat
- Kurento-one2many-call: Live, host click “Presenter” to start live, Viewer click “Viewer” to watch live (demo environment, only one host is supported)
- Kurento-group-call: Enter your name and then enter the room name to start a multi-party meeting
- Kurento-platedetector: Using a camera to recognize license plates (difficult to recognize, difficult to recognize, and even wrong to recognize)
- Kurento-chroma: Will replace the green area of the video with a Picture of Super Mario
- Kurento-crowddetector: Delineate the area (ROI) in the video and flash if there is a crowd in the area
- Kurento-player: specifies the streaming media address, which is pulled and decoded by KMS and then transmitted to the browser in real time via WebRTC
- Kurento-pointerdetector: In several fixed areas, if objects of certain colors wobble in these locations (some colors refer to the colors that can be recognized by the specified filter of KMS), the console of the page will output the events of these objects entering and exiting the area
- These are the detailed steps to quickly deploy KMS and experience the official demo. I hope this article will help you quickly get to know Kurento. In the following articles we will gradually learn more about Kurento development.
You are not alone, Xinchen original accompany all the way
- Java series
- Spring series
- The Docker series
- Kubernetes series
- Database + middleware series
- The conversation series
Welcome to pay attention to the public number: programmer Xin Chen
Wechat search “programmer Xin Chen”, I am Xin Chen, looking forward to enjoying the Java world with you…
Github.com/zq2599/blog…