# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache;
}
# proxy the php scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ .php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /.ht {
# deny all;
#}
}
server {
listen 8080;
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /usr/local/nginx-rtmp-module/; #在nginx-rtmp-module源码根目录
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
【直播流 nginx+ffmpeg搭建流媒体服务器】#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
错误提示:安装ffmpeg出现错误,cannot open shared object file
vi /etc/ld.so.conf
在尾部增加一行:/usr/local/lib
-->ldconfig
温馨提示:如果编译过程中出现一些错误,学会看config.log,里面会有错误提示及解决方法
5、配置好后判断配置是否正确
/usr/local/nginx/sbin/nginx -t6、开始推流,我推的是直播流
-->重启nginx /usr/local/nginx/sbin/nginx -s reload
-->查看是否已经启动流媒体服务器的端口
netstat -anp | grep 1935
-->cd /usr/local/ffmpeg_sources/ffmpeg-3.2.47. 搭建客户端测试环境,本文测试播放器使用的是jwplayer-->准备网页
-->./ffmpeg -re -i "/usr/local/WEB.mp4" -vcodec libx264 -vprofile baseline -acodec aac -ar 44100 -strict -2 -ac 1 -f flv -s 1280x720 -pix_fmt yuv420p -q 10 rtmp://172.19.197.244:1935/myapp/test
-->make && make install
-->下载jwplayer:http://www.longtailvideo.com/players/jw-flv-player/
-->下载后,解压到:/usr/local/nginx/html/
-->建立测试页面test.html,也放到上面目录下 。
<html>找到下图这个网址,然后打开网址将jwplayer.js的代码复制进你之前创建的配置文件中
<head>
<script src=https://www.isolves.com/it/wlyx/fwq/2020-04-26/"jwplayer/jwplayer.js">
</head>
<body>
<div id='my-video'></div>
<script type='text/JAVAscript'>
jwplayer('my-video').setup({
file:'rtmp://172.19.197.244/myapp/test', //#live是applicatioin,test是直播缓存流文件
width:'100%',
aspectratio:'3:2',
fallback:'false',
primary:'flash'
});
</script>
</body>
</html>
ps:由于脚本默认不调用JavaScript函数,所以我们要去官网下载这个函数配置文件,将它放在
/usr/local/nginx/html/jwplayer/jwplayer.js,由于jwplayer.js是没有的,需要自己创建
-->下载网址:https://github.com/jwplayer/jwdeveloper-demos/blob/master/demos/toolbox/live-streaming/index.html
8,使用ffmpeg推流到nginx
推一个本地的mp4到上面配置的myapp上:
ffmpeg -re -i /tmp/ffmpeg_test.mp4 -vcodec copy -acodec copy -f flv "rtmp://127.0.0.1:1935/myapp/test1"
推荐阅读
- 蒙古族资料,合作代理流程
- 淘宝直播好吗 淘宝直播有什么好处
- 茶叶制作流程,绿茶的制作流程
- 绿茶制作工艺流程,绿茶制茶工艺流程
- 铁观音包装盒,用铁观音茶碎末制造茶叶包装盒或罐的工艺方法及产品与流程
- 发型|今夏发型别乱剪,这3种很火很流行,照着剪就对了
- 淘宝直播也可以另外安装美颜软件吗? 淘宝直播怎么出瘦脸功能
- 那些主流编程语言的知识,C语言
- 流汗黄豆为什么恶心 流汗黄豆是什么梗
- 华三防火墙IPS、AV、ACG特征库授权License申请注册流程
