nginx_rtmp 实现mpeg-dash流推送
2017-01-25 18:32
323 查看
参考来源 https://habrahabr.ru/post/204666/
#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 -re -i /home/cyf/Videos/tree.mp4 -vcodec libx264 -vprofile baseline -g 30 -acodec aac -strict -2 -f flv rtmp://localhost/myapp/mystream //转码
本地播放 : 直接浏览器输入
一 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代理指定目录
- 访问Nginx发生SSL connection error的一种情况
- 利用ffmpeg打造播放器直播观看公网rtmp1s延时极致优化
- Nginx+Naxsi部署专业级Web应用防火墙
- CentOS 6.2实战部署Nginx+MySQL+PHP
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- Apache select和Nginx epoll模型区别
- Nginx 学习笔记(一)
- 网站502与504错误分析
- 用zabbix监控nginx_status状态
- 艰难完成 nginx + puma 部署 rails 4的详细记录
- 把Lua编译进nginx步骤方法
- web 应用中常用的各种 cache详解
- 利用python自动生成docker nginx反向代理配置
- Linux系统上配置Nginx+Ruby on Rails+MySQL超攻略
- window+nginx+php环境配置 附配置搭配说明