Preparatory work before starting#
Linux server
(1) KPlayer currently only supports Linux environment and requires hardware environment with x86_64 (amd64) and aarch64 (arm64) CPU architectures. We have statically linked the relevant dependency libraries to the main program, which means you do not need to install any third-party libraries to support the operation of KPlayer. In subsequent iterative versions, cross-platform support will be provided for different CPU architectures and different operating systems.
(2) Here, you can rent a server from mainstream cloud platforms (Alibaba Cloud, Tencent Cloud), and the configuration does not need to be very high. 1 core and 2GB of RAM should be sufficient. You can also use a virtual machine locally as a server, but of course, your own computer must be on 24/7. This method can be used by some small partners who just want to try it out.
Download and install KPlayer#
- Prepare a folder to install KPlayer.
- Enter this folder.
wget http://download.bytelang.cn/kplayer-v0.5.6-linux_amd64.tar.gz
tar zxvf kplayer-v0.5.6-linux_amd64.tar.gz
- After decompression, the installation is complete. Use the following command to check.
./kplayer
Prepare for Bilibili live streaming#
- Real-name authentication
This is self-explanatory and very simple. - Prepare the Bilibili streaming code
Open the Bilibili website, click on "Live" on the homepage, click on the avatar to open the live streaming center, select "My Live Room", and you can view the streaming code (of course, you need to select a category and start the live streaming to see it, so wait for a moment here).
- Create a configuration file
cp config.json.example config.json
Use the cp command to make a copy of the configuration file.
Open the config.json file for editing.
{
"version": "2.0.0",
"resource": {
"lists": [
"/video/example_1.mp4",
"/video/example_2.mp4"
]
},
"output": {
"lists": [
{
"path": "rtmp://127.0.0.1:1935/push"
}
]
}
In the resource -> list section, configure the location of your videos. Note that you need to add a comma after each entry except the last one.
In the output -> list section, configure the streaming address.
Now you can select a category and start the live streaming. Then, concatenate the address and key marked by the dashed line in the above image, and copy it to the configuration file. The configuration file is ready.
Start KPlayer#
./kplayer play start
./kplayer play start --daemon
The above two are start commands. The following is the command for running in the background.
After successful execution, it will output a success log.
After successful background execution, you can check the running log in the /kplayer/log/core.log file.
You can now go to your live room to watch.
Welcome to visit my live room: https://live.bilibili.com/26709867