rtmp与hls流媒体服务器搭建:ubuntu下Nginx搭建初探与rtmp-module的添加
来源:互联网 发布:淘宝网定制牙靠谱吗 编辑:程序博客网 时间:2024/05/01 15:22
前言:感谢开源,感谢战斗民族。现在在做流媒体服务的一些工作,流媒体服务器搭建的网上教程多入牛毛,但是细细查看,发现很多同志贴上来的教程都有些许问题,还有一些是爬别人的数据得来的,排版上也有问题,让新手无所适从。本文也是通过翻看一些优质的博文得到的这篇分享。以下分享的网址就是引用的博文,安利一下。
1. http://redstarofsleep.iteye.com/blog/2123752
2. http://blog.csdn.net/cjsafty/article/details/9108587
3. http://blog.chinaunix.net/uid-20639775-id-154556.html
教程:
1. 下载nginx, openssl, pcre, zlib到一个目录下,如(/home/user),用wget命令,具体可查看下面的各种版本。
nginx-1.8.0.tar.gzopenssl-1.0.1i.tar.gzpcre-8.37.tar.gzzlib-1.2.8.tar.gz
2. tar解压。
tar -zxvf nginx-1.8.0.tar.gztar -zxvf openssl-1.0.1i.tar.gztar -zxvf pcre-8.37.tar.gztar -zxvf zlib-1.2.8.tar.gz
3. git下nginx-rtmp-module(https://github.com/arut/nginx-rtmp-module),具体略。
4. 进入nginx内,配置好,再make和make install。
(这里强调一下,/home/user里的user就是你的用户名,然后是configure的时候最好加入--with-debug)
./configure --prefix=/usr/local/nginx --with-debug --with-pcre=/home/user/pcre/pcre-8.37 --with-zlib=/home/user/zlib/zlib-1.2.8 --with-openssl=/home/user/openssl/openssl-1.0.1i --add-module=/home/user/nginx-rtmp-modulemakemake install
5. 进到(/usr/local/nginx/conf),配置好conf,下面来个简单完整版的
#user nobody;worker_processes 1;#这里可以通过加入debug模式来查看error.log,内容更加丰富error_log logs/error.log debug;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}-------------------------------------@@@rtmp { server { listen 1935; application myapp { live on; } application hls { live on; hls on; hls_path /tmp/hls; } }}---------------------------------------@@@http { #include mime.types; #default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; --------------------------------------------@@@ location /hls { types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root /tmp; add_header Cache-Control no-cache; } --------------------------------------------@@@ location / { root html; index index.html index.htm; }}
加的部分已经在上面标出来了。
6. 进入(/usr/local/nginx/sbin)运行
./ngnix
7. 可以查看端口占用,80,1935是不是在监听
netstat -ltn
8.安装ffmpeg,因源码编译安装在Ubuntu16.04上存在依赖错误故选择安装包安装
sudo apt install ffmpeg
9. 更多测试
1)把rtmp流发给服务器的rtmp实例
ffmpeg -re -i ~/Desktop/test.mp4" -vcodec libx264 -vprofile baseline -acodec aac -ar 44100 -strict -2 -ac 1 -f flv -q 10 rtmp://server:1935/myapp/test
2) 接收rtmp流
rtmp://ip/myapp/test
myapp是ngnix.conf里application设置的,stream为test则是自定义的。
3)把rtmp流发给服务器的hls实例
ffmpeg -re -i ~/Desktop/test.mp4 -vcodec libx264 -vprofile baseline -acodec aac -ar 44100 -strict -2 -ac -1 -f flv -q 10 rtmp://server:1935/hls/test
4)接收hls流
http://ip/hls/test.m3u8
hls是http内的location设置的,访问的是Linux下的(/tmp/hls),test则是按照上面rtmp的test,如果上面是haha,下面也是haha。
5)ngnix主页
http://ip
后言:权限不够的,在命令前加sudo。
- rtmp与hls流媒体服务器搭建:ubuntu下Nginx搭建初探与rtmp-module的添加
- Linux平台下使用nginx与nginx-rtmp-module搭建RTMP+HLS流媒体服务器
- 使用nginx与nginx-rtmp-module搭建 rtmp 流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 基础的名词概念
- Unknown: Failed to write session data (files). Please verify that the current setting of session.s
- OpenStack Grizzly Install Guide(master Single)
- HDU2091(基础题)
- Maven类包冲突终极解决小技若干
- rtmp与hls流媒体服务器搭建:ubuntu下Nginx搭建初探与rtmp-module的添加
- Unity3d UGUI 滚动视图ScrollView的使用教程之简易双肩包
- mysql 复合索引详解
- Java项目的maven介绍
- MySQL中创建外键的错误:1215 Cannot add the foreign key constraint
- MapReduce: 一种简化的大规模集群数据处理法
- CSS深入理解
- 常用正则表达式 总结
- Hadoop运维和Hive调优