目录
整天框架分析
rtmp拉流分析
rtmp推流分析
hls拉流分析
hsl推流分析
http-flv拉流分析
http-flv推流分析
ffmpeg转码分析
首屏秒开技术分析
1.1 RTMP的简介
RTMP是Real Time Messaging Protocol(实时消息传输协议)的首字母缩写。该协议基于TCP,是一个协议族,包括RTMP基本协议及RTMPT/RTMPS/RTMPE等多种变种。RTMP是一种设计用来进行实时数据通信的网络协议,主要用来在Flash/AIR平台和支持RTMP协议的流媒体/交互服务器之间进行音视频和数据通信。支持该协议的软件包括Adobe Media Server/Ultrant Media Server/red5等。
.2 集成FFmpeg目的
Nginx的RTMP模块提供的流媒体功能不足之处就是对很多媒体格式不支持,故需要借助FFmpeg功能来补充。
1.3 FFmpeg官方架构介绍
![40695f4a8e0c66a217b97ffbad12977e.png](https://img-blog.csdnimg.cn/img_convert/40695f4a8e0c66a217b97ffbad12977e.png)
流媒体广播服务器(FFserver),对多个输入源进行转码、重映射、广播
- 输入源(FFmpeg),将音频或视频发送给流媒体播放器
- 媒体播放器
1.4 FFmpeg官方工作模型
![4ddb646968fa5f40aa19e62e5e02b2bd.png](https://img-blog.csdnimg.cn/img_convert/4ddb646968fa5f40aa19e62e5e02b2bd.png)
rtmp推流分析
开发环境
Linux (centos7),Nginx (openresty),nginx-rtmp-module
安装
由于之前已经安装过了openresty,详见博文。这里我们只需要安装nginx-rtmp-module模块即可。
下载并解压模块:
wget https://github.com/arut/nginx-rtmp-module/archive/master.zipunzip master.zip
停止原来的Nginx服务:
nginx -s stop
配置并编辑:
./configure --add-module=/home/nginx-rtmp-module-mastermake
复制Nginx:
## 路径根据自己软件路径自行配置cp /home/openresty/build/nginx-1.11.2/objs/nginx /usr/local/openresty/nginx/sbin
配置rtmp服务:
rtmp { #RTMP服务 server { listen 1935; #//服务端口 chunk_size 4096; #//数据传输块的大小 application vod { play /opt/video; #//视频文件存放位置。 } application live{ #直播 live on; } }}
检查并启动服务:
nginx -tnginx
ffmpeg转码分析
使用shell快速安装视频转码器
#!/bin/bash#1、保证系统可以连到外网,需要下载安装包和依赖包#2、依赖gcc编译器#3、测试命令:ffmpeg -i test.avi out.mp4set -effmDir="/usr/myapp"ffmVer="ffmpeg-3.4.1"yasmVer="yasm-1.3.0"mkdir $ffmDir -pv yum install wget gcc -ycd /usr/local/srcwget http://ffmpeg.org/releases/ffmpeg-3.4.1.tar.bz2wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gztar xf ffmpeg-3.4.1.tar.bz2 tar xf yasm-1.3.0.tar.gz cd $yasmVer./configure && make && make installcd ../$ffmVer./configure --enable-shared --prefix=$ffmDir/ffmpeg && make && make installecho "$ffmDir/ffmpeg/lib" > /etc/ld.so.conf.d/ffmpeg.confldconfigcd $ffmDir/ffmpeg/bin && lsecho -e "033[31m Usage:./ffmpeg -i test.avi out.mp4 033[0m"
总结;需要相关资料的可以后台关注+私信‘资料’分析大家
![46195f49feb0e546fe58a01c12da1e1f.png](https://img-blog.csdnimg.cn/img_convert/46195f49feb0e546fe58a01c12da1e1f.png)