ZLMediaKit/README.md

297 lines
15 KiB
Markdown
Raw Normal View History

![logo](https://raw.githubusercontent.com/ZLMediaKit/ZLMediaKit/master/www/logo.png)
2020-01-07 15:16:01 +08:00
2019-12-24 18:35:46 +08:00
# 一个基于C++11的高性能运营级流媒体服务框架
2020-04-09 22:47:19 +08:00
[![](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ZLMediaKit/ZLMediaKit/blob/master/LICENSE)
[![](https://img.shields.io/badge/language-c++-red.svg)](https://en.cppreference.com/)
[![](https://img.shields.io/badge/platform-linux%20|%20macos%20|%20windows-blue.svg)](https://github.com/ZLMediaKit/ZLMediaKit)
[![](https://img.shields.io/badge/PRs-welcome-yellow.svg)](https://github.com/ZLMediaKit/ZLMediaKit/pulls)
[![](https://github.com/ZLMediaKit/ZLMediaKit/actions/workflows/android.yml/badge.svg)](https://github.com/ZLMediaKit/ZLMediaKit)
[![](https://github.com/ZLMediaKit/ZLMediaKit/actions/workflows/linux.yml/badge.svg)](https://github.com/ZLMediaKit/ZLMediaKit)
[![](https://github.com/ZLMediaKit/ZLMediaKit/actions/workflows/macos.yml/badge.svg)](https://github.com/ZLMediaKit/ZLMediaKit)
[![](https://github.com/ZLMediaKit/ZLMediaKit/actions/workflows/windows.yml/badge.svg)](https://github.com/ZLMediaKit/ZLMediaKit)
[![](https://github.com/ZLMediaKit/ZLMediaKit/actions/workflows/docker.yml/badge.svg)](https://hub.docker.com/r/zlmediakit/zlmediakit/tags)
[![](https://img.shields.io/docker/pulls/zlmediakit/zlmediakit)](https://hub.docker.com/r/zlmediakit/zlmediakit/tags)
2017-04-01 16:42:00 +08:00
2019-12-24 18:35:46 +08:00
## 项目特点
2020-04-09 22:47:19 +08:00
- 基于C++11开发避免使用裸指针代码稳定可靠性能优越。
2021-04-08 18:11:21 +08:00
- 支持多种协议(RTSP/RTMP/HLS/HTTP-FLV/WebSocket-FLV/GB28181/HTTP-TS/WebSocket-TS/HTTP-fMP4/WebSocket-fMP4/MP4/WebRTC),支持协议互转。
2020-04-09 22:47:19 +08:00
- 使用多路复用/多线程/异步网络IO模式开发并发性能优越支持海量客户端连接。
- 代码经过长期大量的稳定性、性能测试,已经在线上商用验证已久。
- 支持linux、macos、ios、android、windows全平台。
- 支持画面秒开、极低延时([500毫秒内最低可达100毫秒](https://github.com/ZLMediaKit/ZLMediaKit/wiki/%E5%BB%B6%E6%97%B6%E6%B5%8B%E8%AF%95))。
- 提供完善的标准[C API](https://github.com/ZLMediaKit/ZLMediaKit/tree/master/api/include),可以作SDK用或供其他语言调用。
- 提供完整的[MediaServer](https://github.com/ZLMediaKit/ZLMediaKit/tree/master/server)服务器,可以免开发直接部署为商用服务器。
- 提供完善的[restful api](https://github.com/ZLMediaKit/ZLMediaKit/wiki/MediaServer%E6%94%AF%E6%8C%81%E7%9A%84HTTP-API)以及[web hook](https://github.com/ZLMediaKit/ZLMediaKit/wiki/MediaServer%E6%94%AF%E6%8C%81%E7%9A%84HTTP-HOOK-API),支持丰富的业务逻辑。
2020-04-09 22:47:19 +08:00
- 打通了视频监控协议栈与直播协议栈对RTSP/RTMP支持都很完善。
2020-08-01 20:56:34 +08:00
- 全面支持H265/H264/AAC/G711/OPUS。
2022-01-13 16:23:15 +08:00
- 功能完善,支持集群、按需转协议、按需推拉流、先播后推、断连续推等功能。
2022-02-17 10:49:23 +08:00
- 极致性能单机10W级别播放器100Gb/s级别io带宽能力。
- 极致体验,[独家特性](https://github.com/ZLMediaKit/ZLMediaKit/wiki/ZLMediakit%E7%8B%AC%E5%AE%B6%E7%89%B9%E6%80%A7%E4%BB%8B%E7%BB%8D)
2022-02-17 11:37:26 +08:00
- [谁在使用zlmediakit?](https://github.com/ZLMediaKit/ZLMediaKit/issues/511)
2022-05-10 15:31:36 +08:00
- 全面支持ipv6网络
2019-12-24 18:35:46 +08:00
## 项目定位
2020-04-09 22:47:19 +08:00
2019-12-24 18:35:46 +08:00
- 移动嵌入式跨平台流媒体解决方案。
- 商用级流媒体服务器。
- 网络编程二次开发SDK。
## 功能清单
2020-09-22 16:07:11 +08:00
### 功能一览
2021-04-09 19:58:40 +08:00
<img width="800" alt="功能一览" src="https://user-images.githubusercontent.com/11495632/114176523-d50fce80-996d-11eb-81f8-0a2e2715ba7b.png">
2020-04-09 22:47:19 +08:00
2020-05-18 09:10:35 +08:00
- RTSP[S]
- RTSP[S] 服务器支持RTMP/MP4/HLS转RTSP[S],支持亚马逊echo show这样的设备
- RTSP[S] 播放器支持RTSP代理支持生成静音音频
- RTSP[S] 推流客户端与服务器
2020-01-06 14:19:15 +08:00
- 支持 `rtp over udp` `rtp over tcp` `rtp over http` `rtp组播` 四种RTP传输方式
- 服务器/客户端完整支持Basic/Digest方式的登录鉴权全异步可配置化的鉴权接口
2019-12-24 18:35:46 +08:00
- 支持H265编码
- 服务器支持RTSP推流(包括`rtp over udp` `rtp over tcp`方式)
2020-08-01 10:32:05 +08:00
- 支持H264/H265/AAC/G711/OPUS编码其他编码能转发但不能转协议
2019-12-24 18:35:46 +08:00
2020-05-18 09:10:35 +08:00
- RTMP[S]
- RTMP[S] 播放服务器支持RTSP/MP4/HLS转RTMP
- RTMP[S] 发布服务器,支持录制发布流
- RTMP[S] 播放器支持RTMP代理支持生成静音音频
- RTMP[S] 推流客户端
2020-01-06 14:19:15 +08:00
- 支持http[s]-flv直播
- 支持websocket-flv直播
2020-08-01 10:32:05 +08:00
- 支持H264/H265/AAC/G711/OPUS编码其他编码能转发但不能转协议
2020-04-04 23:20:42 +08:00
- 支持[RTMP-H265](https://github.com/ksvc/FFmpeg/wiki)
- 支持[RTMP-OPUS](https://github.com/ZLMediaKit/ZLMediaKit/wiki/RTMP%E5%AF%B9H265%E5%92%8COPUS%E7%9A%84%E6%94%AF%E6%8C%81)
2019-12-24 18:35:46 +08:00
2017-04-22 21:45:58 +08:00
- HLS
2020-01-06 14:19:15 +08:00
- 支持HLS文件生成自带HTTP文件服务器
2020-08-01 10:32:05 +08:00
- 通过cookie追踪技术可以模拟HLS播放为长连接可以实现HLS按需拉流、播放统计等业务
2020-05-18 09:10:35 +08:00
- 支持HLS播发器支持拉流HLS转rtsp/rtmp/mp4
2020-08-01 20:56:34 +08:00
- 支持H264/H265/AAC/G711/OPUS编码
2020-09-20 00:21:46 +08:00
- TS
- 支持http[s]-ts直播
- 支持ws[s]-ts直播
2020-09-30 10:30:28 +08:00
- 支持H264/H265/AAC/G711/OPUS编码
- fMP4
- 支持http[s]-fmp4直播
- 支持ws[s]-fmp4直播
2020-09-30 10:30:28 +08:00
- 支持H264/H265/AAC/G711/OPUS编码
2018-12-21 11:09:39 +08:00
2020-08-01 10:32:05 +08:00
- HTTP[S]与WebSocket
2020-01-06 14:19:15 +08:00
- 服务器支持`目录索引生成`,`文件下载`,`表单提交请求`
- 客户端提供`文件下载器(支持断点续传)`,`接口请求器`,`文件上传器`
- 完整HTTP API服务器可以作为web后台开发框架
- 支持跨域访问
2019-12-24 18:35:46 +08:00
- 支持http客户端、服务器cookie
- 支持WebSocket服务器和客户端
- 支持http文件访问鉴权
2020-08-01 10:32:05 +08:00
- GB28181与RTP推流
- 支持UDP/TCP国标RTP(PS或TS)推流服务器可以转换成RTSP/RTMP/HLS等协议
- 支持RTSP/RTMP/HLS转国标推流客户端支持TCP/UDP模式提供相应restful api
2020-08-01 20:56:34 +08:00
- 支持H264/H265/AAC/G711/OPUS编码
2020-10-24 23:33:58 +08:00
- 支持海康ehome推流
2020-04-09 22:47:19 +08:00
2020-08-01 10:32:05 +08:00
- MP4点播与录制
2020-01-06 14:19:15 +08:00
- 支持录制为FLV/HLS/MP4
- RTSP/RTMP/HTTP-FLV/WS-FLV支持MP4文件点播支持seek
2020-08-01 10:32:05 +08:00
- 支持H264/H265/AAC/G711/OPUS编码
2020-05-09 09:59:40 +08:00
2021-09-13 15:37:35 +08:00
- WebRTC
2021-04-08 18:11:21 +08:00
- 支持WebRTC推流支持转其他协议
2021-10-20 14:51:59 +08:00
- 支持WebRTC播放支持其他协议转WebRTC
- 支持双向echo test
- 支持simulcast推流
- 支持上下行rtx/nack丢包重传
2021-09-13 15:37:35 +08:00
- **支持单端口、多线程、客户端网络连接迁移(开源界唯一)**。
2021-10-07 15:53:07 +08:00
- 支持TWCC rtcp动态调整码率
2021-10-20 14:51:59 +08:00
- 支持remb/pli/sr/rr rtcp
- 支持rtp扩展解析
2021-11-18 11:27:01 +08:00
- 支持GOP缓冲webrtc播放秒开
2022-05-10 15:31:36 +08:00
- 支持datachannel
2022-06-04 13:31:36 +08:00
- [SRT支持](./srt/srt.md)
2019-12-24 18:35:46 +08:00
- 其他
2020-01-06 14:23:23 +08:00
- 支持丰富的restful api以及web hook事件
2020-01-06 14:19:15 +08:00
- 支持简单的telnet调试
2019-12-24 18:35:46 +08:00
- 支持配置文件热加载
2020-01-06 14:19:15 +08:00
- 支持流量统计、推拉流鉴权等事件
- 支持虚拟主机,可以隔离不同域名
2019-12-24 18:35:46 +08:00
- 支持按需拉流,无人观看自动关断拉流
2022-01-13 16:23:15 +08:00
- 支持先播放后推流,提高及时推流画面打开率
2020-01-06 14:19:15 +08:00
- 提供c api sdk
2020-05-09 09:59:40 +08:00
- 支持FFmpeg拉流代理任意格式的流
- 支持http api生成并返回实时截图
2022-01-13 16:23:15 +08:00
- 支持按需解复用、转协议当有人观看时才开启转协议降低cpu占用率
2022-01-12 19:54:22 +08:00
- 支持溯源模式的集群部署溯源方式支持rtsp/rtmp/hls/http-ts, 边沿站支持hls, 源站支持多个(采用round robin方式溯源)
2022-01-13 16:08:23 +08:00
- rtsp/rtmp/webrtc推流异常断开后可以在超时时间内重连推流播放器无感知
2020-05-18 09:17:15 +08:00
2019-12-24 18:35:46 +08:00
2020-03-18 15:33:18 +08:00
## 编译以及测试
**编译前务必仔细参考wiki:[快速开始](https://github.com/ZLMediaKit/ZLMediaKit/wiki/%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B)操作!!!**
2019-12-24 18:35:46 +08:00
2020-04-09 22:34:39 +08:00
## 怎么使用
2020-04-09 22:47:19 +08:00
2020-04-09 22:34:39 +08:00
你有三种方法使用ZLMediaKit分别是
2020-04-09 22:47:19 +08:00
- 1、使用c api作为sdk使用请参考[这里](https://github.com/ZLMediaKit/ZLMediaKit/tree/master/api/include).
- 2、作为独立的流媒体服务器使用不想做c/c++开发的,可以参考 [restful api](https://github.com/ZLMediaKit/ZLMediaKit/wiki/MediaServer支持的HTTP-API) 和 [web hook](https://github.com/ZLMediaKit/ZLMediaKit/wiki/MediaServer支持的HTTP-HOOK-API ).
- 3、如果想做c/c++开发,添加业务逻辑增加功能,可以参考这里的[测试程序](https://github.com/ZLMediaKit/ZLMediaKit/tree/master/tests).
2020-04-09 22:34:39 +08:00
2020-03-18 15:33:18 +08:00
## Docker 镜像
2020-04-09 22:47:19 +08:00
2020-03-18 15:33:18 +08:00
你可以从Docker Hub下载已经编译好的镜像并启动它
2020-04-09 22:47:19 +08:00
2020-02-05 23:34:51 +08:00
```bash
2022-06-19 19:39:48 +08:00
#此镜像为github持续集成自动编译推送跟代码(master分支)保持最新状态
docker run -id -p 1935:1935 -p 8080:80 -p 8443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 8000:8000/udp -p 9000:9000/udp zlmediakit/zlmediakit:master
2020-02-05 23:34:51 +08:00
```
2020-04-09 22:47:19 +08:00
2020-04-06 23:52:45 +08:00
你也可以根据Dockerfile编译镜像
2020-04-09 22:47:19 +08:00
2020-02-05 23:34:51 +08:00
```bash
2020-04-06 23:52:45 +08:00
bash build_docker_images.sh
2020-02-05 23:34:51 +08:00
```
2020-09-30 10:30:28 +08:00
## 合作项目
- 可视化管理网站
2021-08-24 12:00:23 +08:00
- [最新的前后端分离web项目,支持webrtc播放](https://github.com/langmansh/AKStreamNVR)
2020-09-30 10:30:28 +08:00
- [基于ZLMediaKit主线的管理WEB网站](https://gitee.com/kkkkk5G/MediaServerUI)
- [基于ZLMediaKit分支的管理WEB网站](https://github.com/chenxiaolei/ZLMediaKit_NVR_UI)
2021-08-24 12:00:23 +08:00
- [一个非常漂亮的可视化后台管理系统](https://github.com/MingZhuLiu/ZLMediaServerManagent)
2020-09-30 10:30:28 +08:00
- 流媒体管理平台
2021-08-24 12:00:23 +08:00
- [GB28181完整解决方案,自带web管理网站,支持webrtc、h265播放](https://github.com/648540858/wvp-GB28181-pro)
2021-04-30 11:41:58 +08:00
- [功能强大的流媒体控制管理接口平台,支持GB28181](https://github.com/chatop2020/AKStream)
2021-11-23 22:47:10 +08:00
- [Go实现的GB28181服务器](https://github.com/panjjo/gosip)
2020-09-30 10:30:28 +08:00
- [node-js版本的GB28181平台](https://gitee.com/hfwudao/GB28181_Node_Http)
- [Go实现的海康ehome服务器](https://github.com/tsingeye/FreeEhome)
- 客户端
2022-06-22 17:03:57 +08:00
- [c sdk完整c#包装库](https://github.com/malegend/ZLMediaKit.Autogen)
2020-09-30 10:30:28 +08:00
- [基于C SDK实现的推流客户端](https://github.com/hctym1995/ZLM_ApiDemo)
- [C#版本的Http API与Hook](https://github.com/chengxiaosheng/ZLMediaKit.HttpApi)
- [DotNetCore的RESTful客户端](https://github.com/MingZhuLiu/ZLMediaKit.DotNetCore.Sdk)
2021-11-18 11:27:01 +08:00
- 播放器
2021-11-24 20:14:29 +08:00
- [基于wasm支持H265的播放器](https://github.com/numberwolf/h265web.js)
2021-11-18 11:27:01 +08:00
- [基于MSE的websocket-fmp4播放器](https://github.com/v354412101/wsPlayer)
2022-05-13 22:52:30 +08:00
- [全国产webrtc sdk(metaRTC)](https://github.com/metartc/metaRTC)
2021-11-24 20:14:29 +08:00
2019-12-24 18:35:46 +08:00
## 授权协议
本项目自有代码使用宽松的MIT协议在保留版权信息的情况下可以自由应用于各自商用、非商业的项目。
2022-09-02 11:46:38 +08:00
但是本项目也零碎的使用了一些其他的[开源代码](https://github.com/ZLMediaKit/ZLMediaKit/wiki/%E4%BB%A3%E7%A0%81%E4%BE%9D%E8%B5%96%E4%B8%8E%E7%89%88%E6%9D%83%E5%A3%B0%E6%98%8E),在商用的情况下请自行替代或剔除;
2020-09-30 10:30:28 +08:00
由于使用本项目而产生的商业纠纷或侵权行为一概与本项目及开发者无关,请自行承担法律风险。
在使用本项目代码时,也应该在授权协议中同时表明本项目依赖的第三方库的协议。
2019-12-24 18:35:46 +08:00
## 联系方式
2020-04-09 22:47:19 +08:00
2020-04-24 10:11:45 +08:00
- 邮箱:<1213642868@qq.com>(本项目相关或流媒体相关问题请走issue流程否则恕不邮件答复)
2022-01-19 17:17:22 +08:00
- QQ群qq群号在wiki中请阅读wiki后再加群
2020-04-09 22:47:19 +08:00
2019-12-24 18:35:46 +08:00
## 怎么提问?
2020-04-09 22:47:19 +08:00
2019-12-24 18:35:46 +08:00
如果要对项目有相关疑问,建议您这么做:
2020-04-09 22:47:19 +08:00
2019-12-24 18:35:46 +08:00
- 1、仔细看下readme、wiki如果有必要可以查看下issue.
- 2、如果您的问题还没解决可以提issue.
- 3、有些问题如果不具备参考性的无需在issue提的可以在qq群提.
- 4、QQ私聊一般不接受无偿技术咨询和支持([为什么不提倡QQ私聊](https://github.com/ZLMediaKit/ZLMediaKit/wiki/%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%8D%E5%BB%BA%E8%AE%AEQQ%E7%A7%81%E8%81%8A%E5%92%A8%E8%AF%A2%E9%97%AE%E9%A2%98%EF%BC%9F)).
2020-04-09 22:47:19 +08:00
2020-09-30 10:30:28 +08:00
## 特别感谢
本项目采用了[老陈](https://github.com/ireader) 的 [media-server](https://github.com/ireader/media-server) 库,
本项目的 ts/fmp4/mp4/ps 容器格式的复用解复用都依赖media-server库。在实现本项目诸多功能时老陈多次给予了无私热情关键的帮助
特此对他表示诚挚的感谢!
2020-01-09 10:06:30 +08:00
## 致谢
2020-04-09 22:47:19 +08:00
2020-01-09 10:06:30 +08:00
感谢以下各位对本项目包括但不限于代码贡献、问题反馈、资金捐赠等各种方式的支持!以下排名不分先后:
[老陈](https://github.com/ireader)
[Gemfield](https://github.com/gemfield)
[南冠彤](https://github.com/nanguantong2)
[凹凸慢](https://github.com/tsingeye)
[chenxiaolei](https://github.com/chenxiaolei)
[史前小虫](https://github.com/zqsong)
[清涩绿茶](https://github.com/baiyfcu)
[3503207480](https://github.com/3503207480)
[DroidChow](https://github.com/DroidChow)
[阿塞](https://github.com/HuoQiShuai)
[火宣](https://github.com/ChinaCCF)
[γ瑞γミ](https://github.com/JerryLinGd)
[linkingvision](https://www.linkingvision.com/)
[茄子](https://github.com/taotaobujue2008)
[好心情](mailto:409257224@qq.com)
2020-04-09 22:17:58 +08:00
[浮沉](https://github.com/MingZhuLiu)
2020-09-20 23:05:13 +08:00
[Xiaofeng Wang](https://github.com/wasphin)
[doodoocoder](https://github.com/doodoocoder)
[qingci](https://github.com/Colibrow)
[swwheihei](https://github.com/swwheihei)
[KKKKK5G](https://gitee.com/kkkkk5G)
[Zhou Weimin](mailto:zhouweimin@supremind.com)
2020-09-30 10:30:28 +08:00
[Jim Jin](https://github.com/jim-king-2000)
[西瓜丶](mailto:392293307@qq.com)
2020-09-30 10:30:28 +08:00
[MingZhuLiu](https://github.com/MingZhuLiu)
[chengxiaosheng](https://github.com/chengxiaosheng)
[big panda](mailto:2381267071@qq.com)
2020-09-30 10:30:28 +08:00
[tanningzhong](https://github.com/tanningzhong)
[hctym1995](https://github.com/hctym1995)
2020-12-27 21:14:46 +08:00
[hewenyuan](https://gitee.com/kingyuanyuan)
[sunhui](mailto:sunhui200475@163.com)
[mirs](mailto:fangpengcheng@bilibili.com)
[Kevin Cheng](mailto:kevin__cheng@outlook.com)
[Liu Jiang](mailto:root@oopy.org)
2021-04-30 11:41:58 +08:00
[along](https://github.com/alongl)
[qingci](mailto:xpy66swsry@gmail.com)
[lyg1949](mailto:zh.ghlong@qq.com)
[zhlong](mailto:zh.ghlong@qq.com)
[大裤衩](mailto:3503207480@qq.com)
[droid.chow](mailto:droid.chow@gmail.com)
2021-01-02 22:10:11 +08:00
[陈晓林](https://github.com/musicwood)
2021-06-28 11:31:11 +08:00
[CharleyWangHZ](https://github.com/CharleyWangHZ)
[Johnny](https://github.com/johzzy)
2021-06-29 18:20:18 +08:00
[DoubleX69](https://github.com/DoubleX69)
2021-07-01 11:03:28 +08:00
[lawrencehj](https://github.com/lawrencehj)
[yangkun](mailto:xyyangkun@163.com)
[Xinghua Zhao](mailto:holychaossword@hotmail.com)
2021-09-29 00:41:10 +08:00
[hejilin](https://github.com/brokensword2018)
2021-11-18 11:27:01 +08:00
[rqb500](https://github.com/rqb500)
2021-12-17 11:53:53 +08:00
[Alex](https://github.com/alexliyu7352)
[Dw9](https://github.com/Dw9)
[明月惊鹊](mailto:mingyuejingque@gmail.com)
[cgm](mailto:2958580318@qq.com)
[hejilin](mailto:1724010622@qq.com)
[alexliyu7352](mailto:liyu7352@gmail.com)
2022-05-13 20:22:19 +08:00
[cgm](mailto:2958580318@qq.com)
[haorui wang](https://github.com/HaoruiWang)
[joshuafc](mailto:joshuafc@foxmail.com)
[JayChen0519](https://github.com/JayChen0519)
[zx](mailto:zuoxue@qq.com)
[wangcker](mailto:wangcker@163.com)
[WuPeng](mailto:wp@zafu.edu.cn)
[starry](https://github.com/starry)
[mtdxc](https://github.com/mtdxc)
[胡刚风](https://github.com/hugangfeng333)
[zhao85](https://github.com/zhao85)
2022-08-05 18:11:46 +08:00
[dreamisdream](https://github.com/dreamisdream)
[dingcan](https://github.com/dcan123)
[Haibo Chen](https://github.com/duiniuluantanqin)
[Leon](https://gitee.com/leon14631)
2022-09-03 14:55:46 +08:00
[custompal](https://github.com/custompal)
[PioLing](https://github.com/PioLing)
[KevinZang](https://github.com/ZSC714725)
[gongluck](https://github.com/gongluck)
2020-09-30 10:30:28 +08:00
## 使用案例
本项目已经得到不少公司和个人开发者的认可,据作者不完全统计,
使用本项目的公司包括知名的互联网巨头、国内排名前列的云服务公司、多家知名的AI独角兽公司
以及一系列中小型公司。使用者可以通过在 [issue](https://github.com/ZLMediaKit/ZLMediaKit/issues/511) 上粘贴公司的大名和相关项目介绍为本项目背书,感谢支持!