三安装nginx rtmp
由于crtcpserver不支持hls,可以使用nginx rtmp进行推流
HTTP Live Streaming(缩写是 HLS)是一个由苹果公司提出的基于HTTP的流媒体网络传输协议。HLS只请求基本的HTTP报文,与实时传输协议(RTP)不同,HLS可以穿过任何允许HTTP数据通过的防火墙或者代理服务器。它也很容易使用内容分发网络来传输媒体流。使用ffmpeg来完成对flv、mp4、mp3等格式的转化。
1 准备工作
Nginx: http://nginx.org
模块:nginx_mod_h264_streaming(支持h264编码的视频)
模块:http_flv_module 支持flv
模块:http_mp4_module 支持mp4
下载地址:
http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
https://github.com/arut/nginx-rtmp-module
2下载及安装Nginx
下载openssl、pcre、zlib
./configure
--prefix=/usr/local/nginx
--with-pcre=/root/freeswitch/pcre/pcre-8.12
--with-zlib=/root/freeswitch/zlib/zlib-1.2.8
--with-http_ssl_module
--with-openssl=/root/freeswitch/openssl/openssl-1.0.1c--add-module=/root/freeswitch/rtmp/nginx-rtmp-module --with-http_stub_status_module
# make && make install
3 配置nginx.conf
修改conf/nginx.conf 支持rtmp服务
# vim conf/nginx.conf
rtmp{
server{
listen1935;
chunk_size4096;
#HLS
# For HLS to work please createadirectory in tmpfs (/tmp/app here)
# for the fragments. Thedirectorycontents is served via HTTP (see
# http{} section in config)
#
# Incoming stream must be inH264/AAC.For iPhones use baseline H264
# profile (see ffmpeg example).
# This example creates RTMP streamfrommovie ready for HLS:
#
# ffmpeg -loglevel verbose -re-imovie.avi -vcodec libx264
# -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1
# -f flv rtmp://localhost:1935/hls/movie
#
# If you need to transcode livestreamuse 'exec' feature.
applicationhls{
liveon;
hlson;
hls_path /tmp/hls;
hls_fragment 5s;
}
applicationlive{
liveon;
recordoff;
}
applicationlive2{
liveon;
recordoff;
}
# video ondemand
applicationvod{
play/var/flvs;
}
applicationvod_http{
playhttp://127.0.0.1/vod;
}
}
}