You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 15KB

4 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. ![logo](https://raw.githubusercontent.com/ZLMediaKit/ZLMediaKit/master/www/logo.png)
  2. # 一个基于C++11的高性能运营级流媒体服务框架
  3. [![](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ZLMediaKit/ZLMediaKit/blob/master/LICENSE)
  4. [![](https://img.shields.io/badge/language-c++-red.svg)](https://en.cppreference.com/)
  5. [![](https://img.shields.io/badge/platform-linux%20|%20macos%20|%20windows-blue.svg)](https://github.com/ZLMediaKit/ZLMediaKit)
  6. [![](https://img.shields.io/badge/PRs-welcome-yellow.svg)](https://github.com/ZLMediaKit/ZLMediaKit/pulls)
  7. [![](https://github.com/ZLMediaKit/ZLMediaKit/actions/workflows/android.yml/badge.svg)](https://github.com/ZLMediaKit/ZLMediaKit)
  8. [![](https://github.com/ZLMediaKit/ZLMediaKit/actions/workflows/linux.yml/badge.svg)](https://github.com/ZLMediaKit/ZLMediaKit)
  9. [![](https://github.com/ZLMediaKit/ZLMediaKit/actions/workflows/macos.yml/badge.svg)](https://github.com/ZLMediaKit/ZLMediaKit)
  10. [![](https://github.com/ZLMediaKit/ZLMediaKit/actions/workflows/windows.yml/badge.svg)](https://github.com/ZLMediaKit/ZLMediaKit)
  11. [![](https://github.com/ZLMediaKit/ZLMediaKit/actions/workflows/docker.yml/badge.svg)](https://hub.docker.com/r/zlmediakit/zlmediakit/tags)
  12. [![](https://img.shields.io/docker/pulls/zlmediakit/zlmediakit)](https://hub.docker.com/r/zlmediakit/zlmediakit/tags)
  13. ## 项目特点
  14. - 基于C++11开发,避免使用裸指针,代码稳定可靠,性能优越。
  15. - 支持多种协议(RTSP/RTMP/HLS/HTTP-FLV/WebSocket-FLV/GB28181/HTTP-TS/WebSocket-TS/HTTP-fMP4/WebSocket-fMP4/MP4/WebRTC),支持协议互转。
  16. - 使用多路复用/多线程/异步网络IO模式开发,并发性能优越,支持海量客户端连接。
  17. - 代码经过长期大量的稳定性、性能测试,已经在线上商用验证已久。
  18. - 支持linux、macos、ios、android、windows全平台。
  19. - 支持画面秒开、极低延时([500毫秒内,最低可达100毫秒](https://github.com/ZLMediaKit/ZLMediaKit/wiki/%E5%BB%B6%E6%97%B6%E6%B5%8B%E8%AF%95))。
  20. - 提供完善的标准[C API](https://github.com/ZLMediaKit/ZLMediaKit/tree/master/api/include),可以作SDK用,或供其他语言调用。
  21. - 提供完整的[MediaServer](https://github.com/ZLMediaKit/ZLMediaKit/tree/master/server)服务器,可以免开发直接部署为商用服务器。
  22. - 提供完善的[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),支持丰富的业务逻辑。
  23. - 打通了视频监控协议栈与直播协议栈,对RTSP/RTMP支持都很完善。
  24. - 全面支持H265/H264/AAC/G711/OPUS。
  25. - 功能完善,支持集群、按需转协议、按需推拉流、先播后推、断连续推等功能。
  26. - 极致性能,单机10W级别播放器,100Gb/s级别io带宽能力。
  27. - 极致体验,[独家特性](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)
  28. - [谁在使用zlmediakit?](https://github.com/ZLMediaKit/ZLMediaKit/issues/511)
  29. - 全面支持ipv6网络
  30. ## 项目定位
  31. - 移动嵌入式跨平台流媒体解决方案。
  32. - 商用级流媒体服务器。
  33. - 网络编程二次开发SDK。
  34. ## 功能清单
  35. ### 功能一览
  36. <img width="800" alt="功能一览" src="https://user-images.githubusercontent.com/11495632/190864440-91c45f8f-480f-43db-8110-5bb44e6300ff.png">
  37. - RTSP[S]
  38. - RTSP[S] 服务器,支持RTMP/MP4/HLS转RTSP[S],支持亚马逊echo show这样的设备
  39. - RTSP[S] 播放器,支持RTSP代理,支持生成静音音频
  40. - RTSP[S] 推流客户端与服务器
  41. - 支持 `rtp over udp` `rtp over tcp` `rtp over http` `rtp组播` 四种RTP传输方式
  42. - 服务器/客户端完整支持Basic/Digest方式的登录鉴权,全异步可配置化的鉴权接口
  43. - 支持H265编码
  44. - 服务器支持RTSP推流(包括`rtp over udp` `rtp over tcp`方式)
  45. - 支持H264/H265/AAC/G711/OPUS编码,其他编码能转发但不能转协议
  46. - RTMP[S]
  47. - RTMP[S] 播放服务器,支持RTSP/MP4/HLS转RTMP
  48. - RTMP[S] 发布服务器,支持录制发布流
  49. - RTMP[S] 播放器,支持RTMP代理,支持生成静音音频
  50. - RTMP[S] 推流客户端
  51. - 支持http[s]-flv直播
  52. - 支持websocket-flv直播
  53. - 支持H264/H265/AAC/G711/OPUS编码,其他编码能转发但不能转协议
  54. - 支持[RTMP-H265](https://github.com/ksvc/FFmpeg/wiki)
  55. - 支持[RTMP-OPUS](https://github.com/ZLMediaKit/ZLMediaKit/wiki/RTMP%E5%AF%B9H265%E5%92%8COPUS%E7%9A%84%E6%94%AF%E6%8C%81)
  56. - HLS
  57. - 支持HLS文件生成,自带HTTP文件服务器
  58. - 通过cookie追踪技术,可以模拟HLS播放为长连接,可以实现HLS按需拉流、播放统计等业务
  59. - 支持HLS播发器,支持拉流HLS转rtsp/rtmp/mp4
  60. - 支持H264/H265/AAC/G711/OPUS编码
  61. - TS
  62. - 支持http[s]-ts直播
  63. - 支持ws[s]-ts直播
  64. - 支持H264/H265/AAC/G711/OPUS编码
  65. - fMP4
  66. - 支持http[s]-fmp4直播
  67. - 支持ws[s]-fmp4直播
  68. - 支持H264/H265/AAC/G711/OPUS编码
  69. - HTTP[S]与WebSocket
  70. - 服务器支持`目录索引生成`,`文件下载`,`表单提交请求`
  71. - 客户端提供`文件下载器(支持断点续传)`,`接口请求器`,`文件上传器`
  72. - 完整HTTP API服务器,可以作为web后台开发框架
  73. - 支持跨域访问
  74. - 支持http客户端、服务器cookie
  75. - 支持WebSocket服务器和客户端
  76. - 支持http文件访问鉴权
  77. - GB28181与RTP推流
  78. - 支持UDP/TCP RTP(PS/TS/ES)推流服务器,可以转换成RTSP/RTMP/HLS等协议
  79. - 支持RTSP/RTMP/HLS等协议转rtp推流客户端,支持TCP/UDP模式,提供相应restful api,支持主动被动方式。
  80. - 支持H264/H265/AAC/G711/OPUS编码
  81. - 支持海康ehome推流
  82. - 支持GB28181主动拉流模式
  83. - MP4点播与录制
  84. - 支持录制为FLV/HLS/MP4
  85. - RTSP/RTMP/HTTP-FLV/WS-FLV支持MP4文件点播,支持seek
  86. - 支持H264/H265/AAC/G711/OPUS编码
  87. - WebRTC
  88. - 支持WebRTC推流,支持转其他协议
  89. - 支持WebRTC播放,支持其他协议转WebRTC
  90. - 支持双向echo test
  91. - 支持simulcast推流
  92. - 支持上下行rtx/nack丢包重传
  93. - **支持单端口、多线程、客户端网络连接迁移(开源界唯一)**。
  94. - 支持TWCC rtcp动态调整码率
  95. - 支持remb/pli/sr/rr rtcp
  96. - 支持rtp扩展解析
  97. - 支持GOP缓冲,webrtc播放秒开
  98. - 支持datachannel
  99. - 支持webrtc over tcp模式
  100. - [SRT支持](./srt/srt.md)
  101. - 其他
  102. - 支持丰富的restful api以及web hook事件
  103. - 支持简单的telnet调试
  104. - 支持配置文件热加载
  105. - 支持流量统计、推拉流鉴权等事件
  106. - 支持虚拟主机,可以隔离不同域名
  107. - 支持按需拉流,无人观看自动关断拉流
  108. - 支持先播放后推流,提高及时推流画面打开率
  109. - 提供c api sdk
  110. - 支持FFmpeg拉流代理任意格式的流
  111. - 支持http api生成并返回实时截图
  112. - 支持按需解复用、转协议,当有人观看时才开启转协议,降低cpu占用率
  113. - 支持溯源模式的集群部署,溯源方式支持rtsp/rtmp/hls/http-ts, 边沿站支持hls, 源站支持多个(采用round robin方式溯源)
  114. - rtsp/rtmp/webrtc推流异常断开后,可以在超时时间内重连推流,播放器无感知
  115. ## 编译以及测试
  116. **编译前务必仔细参考wiki:[快速开始](https://github.com/ZLMediaKit/ZLMediaKit/wiki/%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B)操作!!!**
  117. ## 怎么使用
  118. 你有三种方法使用ZLMediaKit,分别是:
  119. - 1、使用c api,作为sdk使用,请参考[这里](https://github.com/ZLMediaKit/ZLMediaKit/tree/master/api/include).
  120. - 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 ).
  121. - 3、如果想做c/c++开发,添加业务逻辑增加功能,可以参考这里的[测试程序](https://github.com/ZLMediaKit/ZLMediaKit/tree/master/tests).
  122. ## Docker 镜像
  123. 你可以从Docker Hub下载已经编译好的镜像并启动它:
  124. ```bash
  125. #此镜像为github持续集成自动编译推送,跟代码(master分支)保持最新状态
  126. 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
  127. ```
  128. 你也可以根据Dockerfile编译镜像:
  129. ```bash
  130. bash build_docker_images.sh
  131. ```
  132. ## 合作项目
  133. - 可视化管理网站
  134. - [最新的前后端分离web项目,支持webrtc播放](https://github.com/langmansh/AKStreamNVR)
  135. - [基于ZLMediaKit主线的管理WEB网站](https://gitee.com/kkkkk5G/MediaServerUI)
  136. - [基于ZLMediaKit分支的管理WEB网站](https://github.com/chenxiaolei/ZLMediaKit_NVR_UI)
  137. - [一个非常漂亮的可视化后台管理系统](https://github.com/MingZhuLiu/ZLMediaServerManagent)
  138. - 流媒体管理平台
  139. - [GB28181完整解决方案,自带web管理网站,支持webrtc、h265播放](https://github.com/648540858/wvp-GB28181-pro)
  140. - [功能强大的流媒体控制管理接口平台,支持GB28181](https://github.com/chatop2020/AKStream)
  141. - [Go实现的GB28181服务器](https://github.com/panjjo/gosip)
  142. - [node-js版本的GB28181平台](https://gitee.com/hfwudao/GB28181_Node_Http)
  143. - [Go实现的海康ehome服务器](https://github.com/tsingeye/FreeEhome)
  144. - 客户端
  145. - [c sdk完整c#包装库](https://github.com/malegend/ZLMediaKit.Autogen)
  146. - [基于C SDK实现的推流客户端](https://github.com/hctym1995/ZLM_ApiDemo)
  147. - [C#版本的Http API与Hook](https://github.com/chengxiaosheng/ZLMediaKit.HttpApi)
  148. - [DotNetCore的RESTful客户端](https://github.com/MingZhuLiu/ZLMediaKit.DotNetCore.Sdk)
  149. - 播放器
  150. - [基于wasm支持H265的播放器](https://github.com/numberwolf/h265web.js)
  151. - [基于MSE的websocket-fmp4播放器](https://github.com/v354412101/wsPlayer)
  152. - [全国产webrtc sdk(metaRTC)](https://github.com/metartc/metaRTC)
  153. ## 授权协议
  154. 本项目自有代码使用宽松的MIT协议,在保留版权信息的情况下可以自由应用于各自商用、非商业的项目。
  155. 但是本项目也零碎的使用了一些其他的[开源代码](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),在商用的情况下请自行替代或剔除;
  156. 由于使用本项目而产生的商业纠纷或侵权行为一概与本项目及开发者无关,请自行承担法律风险。
  157. 在使用本项目代码时,也应该在授权协议中同时表明本项目依赖的第三方库的协议。
  158. ## 联系方式
  159. - 邮箱:<1213642868@qq.com>(本项目相关或流媒体相关问题请走issue流程,否则恕不邮件答复)
  160. - QQ群:qq群号在wiki中,请阅读wiki后再加群
  161. ## 怎么提问?
  162. 如果要对项目有相关疑问,建议您这么做:
  163. - 1、仔细看下readme、wiki,如果有必要可以查看下issue.
  164. - 2、如果您的问题还没解决,可以提issue.
  165. - 3、有些问题,如果不具备参考性的,无需在issue提的,可以在qq群提.
  166. - 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)).
  167. ## 特别感谢
  168. 本项目采用了[老陈](https://github.com/ireader) 的 [media-server](https://github.com/ireader/media-server) 库,
  169. 本项目的 ts/fmp4/mp4/ps 容器格式的复用解复用都依赖media-server库。在实现本项目诸多功能时,老陈多次给予了无私热情关键的帮助,
  170. 特此对他表示诚挚的感谢!
  171. ## 致谢
  172. 感谢以下各位对本项目包括但不限于代码贡献、问题反馈、资金捐赠等各种方式的支持!以下排名不分先后:
  173. [老陈](https://github.com/ireader)
  174. [Gemfield](https://github.com/gemfield)
  175. [南冠彤](https://github.com/nanguantong2)
  176. [凹凸慢](https://github.com/tsingeye)
  177. [chenxiaolei](https://github.com/chenxiaolei)
  178. [史前小虫](https://github.com/zqsong)
  179. [清涩绿茶](https://github.com/baiyfcu)
  180. [3503207480](https://github.com/3503207480)
  181. [DroidChow](https://github.com/DroidChow)
  182. [阿塞](https://github.com/HuoQiShuai)
  183. [火宣](https://github.com/ChinaCCF)
  184. [γ瑞γミ](https://github.com/JerryLinGd)
  185. [linkingvision](https://www.linkingvision.com/)
  186. [茄子](https://github.com/taotaobujue2008)
  187. [好心情](mailto:409257224@qq.com)
  188. [浮沉](https://github.com/MingZhuLiu)
  189. [Xiaofeng Wang](https://github.com/wasphin)
  190. [doodoocoder](https://github.com/doodoocoder)
  191. [qingci](https://github.com/Colibrow)
  192. [swwheihei](https://github.com/swwheihei)
  193. [KKKKK5G](https://gitee.com/kkkkk5G)
  194. [Zhou Weimin](mailto:zhouweimin@supremind.com)
  195. [Jim Jin](https://github.com/jim-king-2000)
  196. [西瓜丶](mailto:392293307@qq.com)
  197. [MingZhuLiu](https://github.com/MingZhuLiu)
  198. [chengxiaosheng](https://github.com/chengxiaosheng)
  199. [big panda](mailto:2381267071@qq.com)
  200. [tanningzhong](https://github.com/tanningzhong)
  201. [hctym1995](https://github.com/hctym1995)
  202. [hewenyuan](https://gitee.com/kingyuanyuan)
  203. [sunhui](mailto:sunhui200475@163.com)
  204. [mirs](mailto:fangpengcheng@bilibili.com)
  205. [Kevin Cheng](mailto:kevin__cheng@outlook.com)
  206. [Liu Jiang](mailto:root@oopy.org)
  207. [along](https://github.com/alongl)
  208. [qingci](mailto:xpy66swsry@gmail.com)
  209. [lyg1949](mailto:zh.ghlong@qq.com)
  210. [zhlong](mailto:zh.ghlong@qq.com)
  211. [大裤衩](mailto:3503207480@qq.com)
  212. [droid.chow](mailto:droid.chow@gmail.com)
  213. [陈晓林](https://github.com/musicwood)
  214. [CharleyWangHZ](https://github.com/CharleyWangHZ)
  215. [Johnny](https://github.com/johzzy)
  216. [DoubleX69](https://github.com/DoubleX69)
  217. [lawrencehj](https://github.com/lawrencehj)
  218. [yangkun](mailto:xyyangkun@163.com)
  219. [Xinghua Zhao](mailto:holychaossword@hotmail.com)
  220. [hejilin](https://github.com/brokensword2018)
  221. [rqb500](https://github.com/rqb500)
  222. [Alex](https://github.com/alexliyu7352)
  223. [Dw9](https://github.com/Dw9)
  224. [明月惊鹊](mailto:mingyuejingque@gmail.com)
  225. [cgm](mailto:2958580318@qq.com)
  226. [hejilin](mailto:1724010622@qq.com)
  227. [alexliyu7352](mailto:liyu7352@gmail.com)
  228. [cgm](mailto:2958580318@qq.com)
  229. [haorui wang](https://github.com/HaoruiWang)
  230. [joshuafc](mailto:joshuafc@foxmail.com)
  231. [JayChen0519](https://github.com/JayChen0519)
  232. [zx](mailto:zuoxue@qq.com)
  233. [wangcker](mailto:wangcker@163.com)
  234. [WuPeng](mailto:wp@zafu.edu.cn)
  235. [starry](https://github.com/starry)
  236. [mtdxc](https://github.com/mtdxc)
  237. [胡刚风](https://github.com/hugangfeng333)
  238. [zhao85](https://github.com/zhao85)
  239. [dreamisdream](https://github.com/dreamisdream)
  240. [dingcan](https://github.com/dcan123)
  241. [Haibo Chen](https://github.com/duiniuluantanqin)
  242. [Leon](https://gitee.com/leon14631)
  243. [custompal](https://github.com/custompal)
  244. [PioLing](https://github.com/PioLing)
  245. [KevinZang](https://github.com/ZSC714725)
  246. [gongluck](https://github.com/gongluck)
  247. ## 使用案例
  248. 本项目已经得到不少公司和个人开发者的认可,据作者不完全统计,
  249. 使用本项目的公司包括知名的互联网巨头、国内排名前列的云服务公司、多家知名的AI独角兽公司,
  250. 以及一系列中小型公司。使用者可以通过在 [issue](https://github.com/ZLMediaKit/ZLMediaKit/issues/511) 上粘贴公司的大名和相关项目介绍为本项目背书,感谢支持!