加入新文件

master
kelinlang 5 years ago
parent 5429c4abce
commit 4eb47cb15a
  1. 320
      直播工具包/H265知识整理.md
  2. 98
      直播工具包/nginx.conf_bak
  3. 34
      直播工具包/流媒体 nginx-1.9.9编译安装

@ -0,0 +1,320 @@
#服务器
## nginx-rtmp 修改版 [已编译运行]
支持rtmp、http-flv、http-ts、hls、hls+(内存切片) 直播服务( 支持mp3、h265编码 )
https://github.com/im-pingo/nginx-rtmp-module
其它参考:
https://github.com/adwpc/nginx-rtmp-module
https://github.com/aileone/nginx-rtmp-module <---重要
**已在内网服务器部署**,能正常rtmp推流和hls切片工作
```
http://192.168.0.18/rtmp_stat
```
## ZLMediakit [已编译]
打包多种流媒体协议(RTSP/RTMP/HLS/HTTP-FLV/Websocket-FLV),支持协议间的互相转换
https://github.com/xiongziliang/ZLMediaKit
## media-server [参考]
libmpeg
https://github.com/ireader/media-server
https://github.com/ireader/media-server/tree/master/libmpeg
## SRS
打入H265 patch后可支持h265 rtmp,但是无法保存hls文件
https://github.com/ossrs/srs
## EasyDarwin
RTSP推模式转发、RTSP拉模式转发、录像、检索、回放、关键帧缓存、秒开画面、RESTful接口、WEB后台管理、分布式负载均衡
https://github.com/EasyDarwin/EasyDarwin
## gpac
https://github.com/gpac/gpac
## shaka-packager
https://github.com/google/shaka-packager
# 播放器
## 播放推流SDK
daniuSDK 需收费
https://github.com/daniulive/SmarterStreaming
## OBS
Obs Studio 插件,腾讯云支持rtmp H265+quic加速推流
https://mc.qcloudimg.com/static/qc_doc/e1f3e604039cfe8c824f99fbc0cb8880/doc-Mobile+Live+Video+Broadcasting-Obs+Studio+Plugin.pdf
## ffmpeg
libx265 encoder
https://trac.ffmpeg.org/wiki/Encode/H.265
增加H265 rtmp推流支持
https://github.com/ksvc/FFmpeg/wiki/instructions
https://github.com/ksvc/FFmpeg/wiki
https://github.com/CDN-Union/Code/tree/master/flv265-ChinaNetCenter
https://www.jianshu.com/p/ac7d4037add7
参考链接:
https://blog.csdn.net/smallhujiu/article/details/81703434
## WEB播放器
### WasmVideoPlayer
使用WASM、FFmpeg、WebGL、Web Audio等组件实现了一个简易的支持H265的Web播放器,作为探索、验证
https://github.com/sonysuqin/WasmVideoPlayer
### 金山云H265 Web播放器
在支持WebAssembly的浏览器上播放FLVhttp-flv协议的直播视频和mp4格式的点播视频。
https://github.com/ksvc/h265webplayer
demo: https://roblin.cn/wasm/
花椒直播 webassembly方案
https://mlog.club/article/18560
在 Web 端进行软解码首先会想到使用 JavaScript。libde265.js 是用 C 开发的开源 H.265 编解码器 libde265 的 JavaScript 版本(确切地说是 libde265 的 asm.js 版本,后面会说明)。经测试,使用 libde265.js 并不是一个音视频播放的完善方案,存在帧率偏低和音视频不同步等问题。此外,JavaScript 作为解释型脚本语言,对于 H.265 解码这种重度 CPU 密集型的计算任务而言,也不是理想的选择,于是继续探寻更优方案。
Web端H.265播放器研发解密
https://fed.taobao.org/blog/2019/03/19/web-player-h265/
通过WebAssembly在移动端解码H.265
https://cloud.tencent.com/developer/article/1453425
## Android/iOS video player
### ijkplayer
h265 is disabled by default, you need to modify config/module-lite.sh to enable it, see README.
https://github.com/bilibili/ijkplayer
mpegts 支持H265只能在PC、Android浏览器上播放 iOS不行
https://blog.csdn.net/smallhujiu/article/details/81703434
RTMP进行了标准扩展,播放器上ijkplayer也扩展了该修改。
### ZFPlayer
基于AVPlayer,支持横屏、竖屏(全屏播放还可锁定屏幕方向),上下滑动调节音量、屏幕亮度,左右滑动调节播放进度。
https://github.com/Sky0372Lsk/ZFPlayer
# 流媒体协议
## RTSP
Server:ZLMediaKit 支持H265/H264/AAC codec.
参考链接:
RTP Payload Format for High Efficiency Video Coding (HEVC)
https://www.rfc-editor.org/rfc/pdfrfc/rfc7798.txt
如何支持RTSP播放H.265(HEVC)流
https://blog.csdn.net/renhui1112/article/details/81212213
如何对RTSP播放器做功能和性能评估
https://cloud.tencent.com/developer/article/1535580
## RTMP
FLV H265直播相关
[https://toss156.github.io/2018/01/10/FLV%20H265直播相关/](https://toss156.github.io/2018/01/10/FLV H265直播相关/)
https://github.com/WangLCG/C-plus-plus/tree/1599f6a32a1b7023f744f8d7a6e94a4669fccdb0
支持hevc flv ffmpeg已完成编译
```
/root/ffmpeg_sources/ffmpeg
```
修改文件:
```
libavformat/flv.h
libavformat/flvenc.c
libavformat/flvdec.c
```
nginx-rtmp stat模块无法准确识别H265编码
测试推流命令行:
```
~/bin/ffmpeg -re -i rtsp://192.168.3.101/ch01 -c:v libx265 -profile:v main -c:a aac -b:a 128k -f flv rtmp://127.0.0.1:1935/live/test
```
## TS
H265封装成TS流,查看openHEVC-ffmpeg-2.5源代码,及一些H265的TS流视频文件,基本的方式跟H264是一样的,这里主要注意的地方就是流类型不一样,H264的值为0x1b,H265的值为:0x24
**MPEG-2 TS**
https://blog.csdn.net/smallhujiu/article/details/80753765
转格式:
```
ffmpeg -i input.mp4 -c copy output.ts
ffmpeg -i input.mp4 -c copy output.flv
#从1.mp4 copy一个文件,使其moov头在尾部
ffmpeg -i 1.mp4 -c copy -f mp4 output.mp4
#从1.mp4 copy一个文件,使其moov头在头部:
ffmpeg -i 1.mp4 -c copy -f mp4 -movflags faststart output2.mp4
#测试flv->ts
~/bin/ffmpeg -i rtmp://127.0.0.1:1935/live/testh265 -c copy -y -f mpegts 265.ts
报错:
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
```
GPAC可以把x265生成的hevc流(.hevc)打包成.mp4和.ts文件,其使用方法如下:
**MP4Box**
```
./MP4Box -add name_of_annexB_bitstream.(bit,bin,265) -fps 50 -new output.mp4
./MP4Box -v -add Catus_1920x1080_50_qp32.bin:FMT=HEVC -fps 50 -new output.mp4
./MP4Client output.mp4 # to play HEVC mp4 content
```
**mp42ts**
```
./mp42ts -prog=hevc.mp4 -dst-file=test.ts
./mp42ts -prog=output.mp4 -dst-file=hevc.ts
./MP4Client test.ts # to play HEVC transport streams
```
## HLS
ZLMediakia支持 RTSP[S] --> HLS H265
HEVC支持苹果HLS的几个关键问题
https://blog.csdn.net/vn9PLgZvnPs1522s82g/article/details/79237855
# 直播平台 和 CDN
## 金山云
https://www.ksyun.com/proservice/cloud_live
## 腾讯云
https://cloud.tencent.com/document/product/267/32831
## 京东云
https://www.jdcloud.com/cn/products/live-video
## 虎牙直播
虎牙直播目前支持H.264和H.265标准。
https://help.huya.com/298
# 市场情况
HEVC、AV1、VVC:如何理解2019年的编解码器世界
https://juejin.im/post/5d7f2f376fb9a06acd45529e
编解码器之战:AV1、HEVC、VP9和VVC
https://zhuanlan.zhihu.com/p/49503955
腾讯V265编码器:给用户以完备的265体验
https://blog.csdn.net/vn9PLgZvnPs1522s82g/article/details/100977340

@ -0,0 +1,98 @@
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
worker_rlimit_nofile 102400;
worker_rlimit_core 2G;
working_directory /tmp;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
stream_zone buckets=1024 streams=4096;
rtmp {
server {
listen 1935;
application live {
send_all off;
zero_start off;
live on;
hls on;
hls_path /tmp/hls;
hls2memory on;
mpegts_cache_time 20s;
hls2_fragment 1300ms;
hls2_max_fragment 1800ms;
hls2_playlist_length 3900ms;
wait_key on;
wait_video on;
cache_time 2s;
low_latency on;
fix_timestamp 2000ms;
# h265 codecid, default 12
hevc_codecid 12;
}
# HLS live config
application hls{
live on;
hls on;
hls_path /home/workspace/install/nginx-1.17.6/www/hls;
hls_fragment 5s;
}
}
}
http {
server {
listen 8080;
location / {
chunked_transfer_encoding on;
root html/;
}
location /flv {
flv_live 1935 app=live;
}
location /ts {
ts_live 1935 app=live;
}
location /rtmp_stat {
rtmp_stat all;
rtmp_stat_stylesheet /stat.xsl;
}
location /xstat {
rtmp_stat all;
}
location /sys_stat {
sys_stat;
}
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /home/workspace/install/nginx-1.17.6/www/;
add_header Cache-Control no-cache;
}
location /hls2 {
hls2_live 1935 app=live;
}
location /dash {
# Serve DASH fragments
root /tmp;
add_header Cache-Control no-cache;
}
}
}

@ -14,7 +14,7 @@ tar -zxvf xxxx.tar.gz
./configure --prefix=/home/kelinlang/workspace/install/nginx_rtmp/nginx-1.9.9 --with-pcre=/home/kelinlang/workspace/server/nginx/pcre-8.34 --with-openssl=/home/kelinlang/workspace/server/nginx/openssl-1.0.2d --add-module=/home/kelinlang/workspace/server/nginx/nginx-rtmp-module --add-module=/home/kelinlang/workspace/server/nginx/nginx-rtmp-module/hls ./configure --prefix=/home/kelinlang/workspace/install/nginx_rtmp/nginx-1.9.9 --with-pcre=/home/kelinlang/workspace/server/nginx/pcre-8.34 --with-openssl=/home/kelinlang/workspace/server/nginx/openssl-1.0.2d --add-module=/home/kelinlang/workspace/server/nginx/nginx-rtmp-module --add-module=/home/kelinlang/workspace/server/nginx/nginx-rtmp-module/hls
1.17.6版本配置 1.17.6版本配置
./configure --prefix=/home/kelinlang/workspace/install/nginx_rtmp/nginx-1.17.6 --add-module=../nginx-client-module --add-module=../nginx-multiport-module --add-module=../nginx-toolkit-module --add-module=../nginx-rtmp-module --with-cc-opt="-Wno-error" ./configure --prefix=/home/kelinlang/workspace/install/nginx_rtmp/nginx-1.17.6 --add-module=../nginx-client-module --add-module=../nginx-multiport-module --add-module=../nginx-toolkit-module --add-module=../nginx-rtmp-module --with-http_ssl_module --with-cc-opt="-Wno-error"
3. 执行make -j8&& make install 3. 执行make -j8&& make install
@ -22,6 +22,8 @@ tar -zxvf xxxx.tar.gz
./configure --with-cc-opt="-Wno-error" ./configure --with-cc-opt="-Wno-error"
CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I/home/kelinlang/workspace/server/nginx/nginx-rtmp-module CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I/home/kelinlang/workspace/server/nginx/nginx-rtmp-module
修改连接地址:/etc/ld.so.conf ldconfig
4.rtmp://192.168.3.157:1395/mylive/rtmpstream 4.rtmp://192.168.3.157:1395/mylive/rtmpstream
5.启动 5.启动
6.查进程 ps -ef | grep nginx 6.查进程 ps -ef | grep nginx
@ -39,12 +41,27 @@ ffmpeg -re -i E:\YunvaProject\视频文件\VID_20190104_111210.mp4 -f flv rtmp:/
./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1.mp4 -c copy -f flv rtmp://192.168.0.18:1935/live/test ./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1.mp4 -c copy -f flv rtmp://192.168.0.18:1935/live/test
./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1.mp4 -c copy -f flv rtmp://192.168.2.162:1935/live/test ./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1.mp4 -c copy -f flv rtmp://192.168.2.162:1935/live/test
./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c copy -f flv rtmp://192.168.2.162:1935/live/test ./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c copy -f flv rtmp://192.168.2.162:1935/live/test
./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c copy -f flv rtmp://192.168.2.162:1935/hls/test
./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c copy -f rtsp rtsp://192.168.2.162:1935/live/test
./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c copy -f rtsp rtsp://192.168.2.162:5555/live/test
./ffmpeg -i rtsp://192.168.2.162:5555/live/test -c copy -f flv rtmp://192.168.2.162:1935/hls/test
./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c copy -f flv rtmp://192.168.0.18:1935/live/test ./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c copy -f flv rtmp://192.168.0.18:1935/live/test
./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1.mp4 -c copy -f flv rtmp://192.168.2.162:1935/live/test
./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c copy -f flv /home/kelinlang/workspace/testFiles/E1h265.flv ./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c copy -f flv /home/kelinlang/workspace/testFiles/E1h265.flv
./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1.mp4 -c copy -f flv /home/kelinlang/workspace/testFiles/E1.flv
./ffmpeg -re -i rtsp://192.168.3.101/ch01 -c:v libx265 -c:a aac -b:a 128k -f flv rtmp://192.168.0.18:1935/live/test ./ffmpeg -re -i rtsp://192.168.3.101/ch01 -c:v libx265 -c:a aac -b:a 128k -f flv rtmp://192.168.0.18:1935/live/test
./ffmpeg -re -i rtsp://192.168.3.101/ch01 -c:v -c:a aac -b:a 128k -f flv rtmp://192.168.0.18:1935/live/test ./ffmpeg -re -i rtsp://192.168.3.101/ch01 -f flv rtmp://192.168.0.18:1935/live/test
./ffmpeg -re -i rtsp://192.168.3.101/ch01 -f flv rtmp://192.168.2.162:1935/live/test
~/bin/ffmpeg -re -i rtsp://192.168.3.101/ch01 -c:v libx265 -profile:v main -c:a aac -b:a 128k -f flv rtmp://192.168.2.162:1935/live/test ~/bin/ffmpeg -re -i rtsp://192.168.3.101/ch01 -c:v libx265 -profile:v main -c:a aac -b:a 128k -f flv rtmp://192.168.2.162:1935/live/test
~/bin/ffmpeg -re -i rtsp://192.168.3.101/ch01 -c:v libx265 -profile:v main -c:a aac -b:a 128k -f flv /home/kiloview/ch01_h265.flv
端口查看命令:netstat -ntpl 端口查看命令:netstat -ntpl
@ -52,12 +69,23 @@ ffmpeg -re -i E:\YunvaProject\视频文件\VID_20190104_111210.mp4 -f flv rtmp:/
8.播放 8.播放
./ffplay /home/kelinlang/workspace/testFiles/E1.mp4 ./ffplay /home/kelinlang/workspace/testFiles/E1.mp4
./ffplay /home/kelinlang/workspace/testFiles/E1h265.mp4 ./ffplay /home/kelinlang/workspace/testFiles/E1h265.mp4
./ffplay /home/kelinlang/workspace/testFiles/E1h265.flv
./ffplay rtmp://192.168.0.18:1935/live/test
./ffplay rtmp://192.168.2.162:1935/live/test ./ffplay rtmp://192.168.2.162:1935/live/test
./ffplay http://192.168.2.162:8080/hls/test.m3u8
重封装 重封装
./ffmpeg -re -i ./E1.mp4 -i ./Record-null.ts -map 0:0 -map 0:1 -map 1:0 -map 1:1 -c copy -program title=CCTV1:program_num=1:st=0:st=1 -program title=CCTV2:program_num=2:st=2:st=3 -f mpegts "udp://192.168.2.34:1234?pkt_size=1316" ./ffmpeg -re -i ./E1.mp4 -i ./Record-null.ts -map 0:0 -map 0:1 -map 1:0 -map 1:1 -c copy -program title=CCTV1:program_num=1:st=0:st=1 -program title=CCTV2:program_num=2:st=2:st=3 -f mpegts "udp://192.168.2.34:1234?pkt_size=1316"
./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1.mp4 -i /home/kelinlang/workspace/testFiles/Record-null.ts -map 0:0 -map 0:1 -map 1:0 -map 1:1 -c copy -program title=CCTV1:program_num=1:st=0:st=1 -program title=CCTV2:program_num=2:st=2:st=3 -f mpegts /home/kelinlang/workspace/testFiles/tstest.ts
./ffmpeg -i /home/kelinlang/workspace/testFiles/E1.mp4 -f hevc /home/kelinlang/workspace/testFiles/E1_h265_2.mp4
FFmpeg编译 FFmpeg编译
./configure --enable-shared --enable-static --enable-ffplay --prefix=/home/kelinlang/workspace/install/ffmpeg ./configure --enable-shared --enable-static --enable-ffplay --prefix=/home/kelinlang/workspace/install/ffmpeg
./configure --enable-shared --enable-static --enable-ffplay --prefix=/home/kelinlang/workspace/install/ffmpeg3.3
./configure --enable-shared --enable-static --enable-ffplay --prefix=/home/kelinlang/workspace/install/ffmpegDev/3.3
./configure --enable-shared --enable-static --enable-ffplay --prefix=/home/kelinlang/workspace/install/ffmpegDev/master
git config credential.helper store
git rm -r --cached
Loading…
Cancel
Save