//1, 安装 docker,docker-compose
...
//2, 制作docker镜像
git clone https://github.com/chenxiaolei/ZLMediaKit
docker build -t cl-zlmedia -f ./docker/Dockerfile .
//3, 找个地方运行 docker 容器
cp ZLMediaKit/docker/docker-compose.example.yml any_dir/docker-compose.yml
cd any_dir
docker-compose up -d
//4, 访问管理页面
open browser: http://127.0.0.1:10800
RTSP/RTMP/HLS/HTTP-FLV),and support Inter-protocol conversion.RTSP
rtp over udp rtp over tcp rtp over http rtp udp multicast .RTMP
HLS
HTTP[S]
Others
Protocol conversion:
| protocol/codec | H264 | H265 | AAC | other |
|---|---|---|---|---|
| RTSP[S] --> RTMP/HTTP[S]-FLV/FLV | Y | N | Y | N |
| RTMP --> RTSP[S] | Y | N | Y | N |
| RTSP[S] --> HLS | Y | Y | Y | N |
| RTMP --> HLS | Y | N | Y | N |
| RTSP[S] --> MP4 | Y | N | Y | N |
| RTMP --> MP4 | Y | N | Y | N |
| MP4 --> RTSP[S] | Y | N | Y | N |
| MP4 --> RTMP | Y | N | Y | N |
| feature/codec | H264 | H265 | AAC | other |
|---|---|---|---|---|
| RTSP[S] push | Y | Y | Y | Y |
| RTSP proxy | Y | Y | Y | N |
| RTMP push | Y | Y | Y | Y |
| RTMP proxy | Y | N | Y | N |
| feature/transport | tcp | udp | http | udp_multicast |
|---|---|---|---|---|
| RTSP[S] Play Server | Y | Y | Y | Y |
| RTSP[S] Push Server | Y | Y | N | N |
| RTSP Player | Y | Y | N | Y |
| RTSP Pusher | Y | Y | N | N |
| Server | Y/N |
|---|---|
| RTSP[S] Play Server | Y |
| RTSP[S] Push Server | Y |
| RTMP | Y |
| HTTP[S]/WebSocket | Y |
| Client | Y/N |
|---|---|
| RTSP Player | Y |
| RTSP Pusher | Y |
| RTMP Player | Y |
| RTMP Pusher | Y |
| HTTP[S] | Y |
It is recommended to compile on Ubuntu or MacOS,compiling on windows is cumbersome, and some features are not compiled by default.
My environment
Guidance
# If it is on centos6.x, you need to install the newer version of GCC and cmake first,
# and then compile manually according to the script "build_for_linux.sh".
# If it is on a newer version of a system such as Ubuntu or Debain,
# step 4 can be manipulated directly.
# 1、Install GCC5.2 (this step can be skipped if the GCC version is higher than 4.7)
sudo yum install centos-release-scl -y
sudo yum install devtoolset-4-toolchain -y
scl enable devtoolset-4 bash
# 2、Install cmake (this step can be skipped if the cmake version is higher than 3.1)
tar -xvf cmake-3.10.0-rc4.tar.gz #you need download cmake source file manually
cd cmake-3.10.0-rc4
./configure
make -j4
sudo make install
# 3、Switch to high version GCC
scl enable devtoolset-4 bash
# 4、build
cd ZLMediaKit
./build_for_linux.sh
My environment
Guidance
cd ZLMediaKit
./build_for_mac.sh
This build method is no longer recommended.It is recommended that make Xcode project by yourself.
My environment
Same with Build on macOS
Guidance
cd ZLMediaKit
./build_for_ios.sh
You can also generate Xcode projects and recompile them:
cd ZLMediaKit
mkdir -p build
cd build
# Generate Xcode project, project file is in build directory
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/iOS.cmake -DIOS_PLATFORM=SIMULATOR64 -G "Xcode"
Now you can open android sudio project in Android folder,this is a aar library and damo project.
My environment
Guidance
cd ZLMediaKit
export ANDROID_NDK_ROOT=/path/to/ndk
./build_for_android.sh
1 Enter the ZLMediaKit directory and execute git submodule update -- init downloads the code for ZLToolKit
2 Open the project with cmake-gui and generate the vs project file.
3 Find the project file (ZLMediaKit.sln), double-click to open it with vs2017.
4 Choose to compile Release version. Find the target file and run the test case.
As server:
TcpServer::Ptr rtspSrv(new TcpServer());
TcpServer::Ptr rtmpSrv(new TcpServer());
TcpServer::Ptr httpSrv(new TcpServer());
TcpServer::Ptr httpsSrv(new TcpServer());
rtspSrv->start<RtspSession>(mINI::Instance()[Config::Rtsp::kPort]);
rtmpSrv->start<RtmpSession>(mINI::Instance()[Config::Rtmp::kPort]);
httpSrv->start<HttpSession>(mINI::Instance()[Config::Http::kPort]);
httpsSrv->start<HttpsSession>(mINI::Instance()[Config::Http::kSSLPort]);
As player:
MediaPlayer::Ptr player(new MediaPlayer());
weak_ptr<MediaPlayer> weakPlayer = player;
player->setOnPlayResult([weakPlayer](const SockException &ex) {
InfoL << "OnPlayResult:" << ex.what();
auto strongPlayer = weakPlayer.lock();
if (ex || !strongPlayer) {
return;
}
auto viedoTrack = strongPlayer->getTrack(TrackVideo);
if (!viedoTrack) {
WarnL << "none video Track!";
return;
}
viedoTrack->addDelegate(std::make_shared<FrameWriterInterfaceHelper>([](const Frame::Ptr &frame) {
//please decode video here
}));
});
player->setOnShutdown([](const SockException &ex) {
ErrorL << "OnShutdown:" << ex.what();
});
//rtp transport over tcp
(*player)[Client::kRtpType] = Rtsp::RTP_TCP;
player->play("rtsp://admin:[email protected]/");
As proxy server:
//support rtmp and rtsp url
//just support H264+AAC
auto urlList = {"rtmp://live.hkstv.hk.lxdns.com/live/hks",
"rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov"};
map<string , PlayerProxy::Ptr> proxyMap;
int i=0;
for(auto url : urlList){
PlayerProxy::Ptr player(new PlayerProxy("live",to_string(i++).data()));
player->play(url);
proxyMap.emplace(string(url),player);
}
As puser:
PlayerProxy::Ptr player(new PlayerProxy("app","stream"));
player->play("rtmp://live.hkstv.hk.lxdns.com/live/hks");
RtmpPusher::Ptr pusher;
NoticeCenter::Instance().addListener(nullptr,Config::Broadcast::kBroadcastRtmpSrcRegisted,
[&pusher](BroadcastRtmpSrcRegistedArgs){
const_cast<RtmpPusher::Ptr &>(pusher).reset(new RtmpPusher(app,stream));
pusher->publish("rtmp://jizan.iok.la/live/test");
});
MIT License
Copyright (c) 2016-2019 xiongziliang <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Content type
Image
Digest
Size
236.6 MB
Last updated
almost 6 years ago
docker pull zishuo/zlmediakit