您的位置:首页 > 运维架构 > Nginx

nginx_rtmp 实现mpeg-dash流推送

2017-01-25 18:32 323 查看
参考来源  https://habrahabr.ru/post/204666/


一 nginx 配置  

   nginx.conf   内容如下

#user nobody;
worker_processes 1;

error_log logs/error.log debug;

events {
worker_connections 1024;
}

rtmp {
server {
listen 1935;

application myapp {
live on;
dash on;
dash_path /tmp/dash;
}
}
}

http {
server {
listen 8080;

location /dash {
root /tmp;
add_header Cache-Control no-cache;
add_header 'Access-Control-Allow-Origin' '*';
}
location /dash.js { //dash.js 安装目录下的baseline.html ,提供播放dash流的例子
root /home/cyf/Downloads;

}
}
}

开启  /usr/local/nginx/sbin/nginx 
关闭 /usr/local/nginx/sbin/nginx  -s stop

二 ffmpeg 推送流

./ffmpeg -re -i /home/cyf/Videos/tree.mp4 -c copy -f flv rtmp://localhost/myapp/mystream    //不转码

./ffmpeg -re -i /home/cyf/Videos/tree.mp4 -vcodec libx264 -vprofile baseline -g 30 -acodec aac -strict -2 -f flv rtmp://localhost/myapp/mystream  //转码

三 浏览器播放

 使用firefox 
  本地播放 : 直接浏览器输入
http://localhost:8080/dash.js/baseline.html   读取baseline.html内容 其中的mpd url为

http://localhost:8080/dash/mystream.mpd

远端播放:浏览器打开baseline.html 需要加载dash.all.js


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx rtmp