【原创+史上最全】Nginx+ffmpeg实现流媒体直播点播系统
#centos6.6安装搭建nginx+ffmpeg流媒体服务器
#此系统实现了视频文件的直播及缓存点播,并支持移动端播放(支持Apple和Android端)
#系统需要自行安装,流媒体服务器配置完成之后桌面可能挂掉,以后维护需要进命令行进行操作
#必须按照以下步骤配置流媒体服务器,每一步必须要完成才可以配置成功
# "#"是文档注释内容 "--"也是注释内容
# 1.首先设置服务器IP地址,并更改为自动连接
# 2.修改系统时间和时区为当前时间
# 3.关闭防火墙
#在控制台进行如下操作(需要登录root账号): 安装所有的依赖包:
yum -y install gcc glibc glibc-devel make nasm pkgconfig lib-devel openssl-devel expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_64 #在usr/local/目录下面新建nginx文件夹
#打开命令窗口
#输入:
mkdir soft-source
cd soft-source #安装git
wget http://codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.xz
xz -d git-latest.tar.xz
tar xf git-latest.tar
#cd进入的是当前安装的日期
cd git-2014-12-29
autoconf
./configure
make
make install
git --version --查看git的版本
cd .. #安装zlib
wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make install
cd .. #安装pcre
wget http://exim.mirror.fr/pcre/pcre-8.12.tar.gz
tar zxvf pcre-8.12.tar.gz
cd pcre-8.12
./configure
make
# make的时候如果出现错误:
# libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
# libtool: compile: Try `libtool --help' for more information.
# make[1]: *** [pcrecpp.lo] Error 1
# make[1]: Leaving directory `/home/mfcai/pcre-8.10'
# make: *** [all] Error 2
# make install
执行:yum install gcc gcc-c++ kernel-devel
然后:./configure
make
make install
cd .. #安装yadmi给flv视频添加关键帧
wget http://sourceforge.net/projects/yamdi/files/yamdi/1.4/yamdi-1.4.tar.gz
tar xzvf yamdi-1.4.tar.gz
cd yamdi-1.4
make
make install
cd .. #安装OpenSSL
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz
cd openssl-1.0.1c
./config
make
make install
cd .. #安装ffmpeg及其依赖包:
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel 安装Yasm
cd /usr/local/nginx
mkdir ffmpeg_sources
cd ffmpeg_sources
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xzvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make
make install
cd .. #安装ffmpeg
cd /ffmpeg_sources
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
./configure
make install #ffmpeg正常安装后执行ffmpeg时出现如下错误: # ffmpeg: error while loading shared libraries: libavdevice.so.53: cannot open shared object file: No such file or directory #解决办法: vi /etc/ld.so.conf #加入:
/usr/local/lib #执行
ldconfig #安装nginx模块
cd /usr/local/nginx/soft-source
wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
tar zxvf nginx_mod_h264_streaming-2.2.7.tar.gz
git clone git://github.com/arut/nginx-rtmp-module.git #nginx安装
wget http://nginx.org/download/nginx-1.6.0.tar.gz
tar zxvf nginx-1.6.0.tar.gz
cd nginx-1.6.0 #编译安装nginx(直接复制nginx_configure.sh至nginx-1.6.0目录,文件在附件中)
cp nginx_configure.sh /usr/local/nginx/soft-source/nginx-1.6.0
chmod +x nginx_configure.sh
./nginx_configure.sh
make #在执行make的时候可能出现错误
# /root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: In function ‘ngx_streaming_handler’:
# /root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c:158: error: ‘ngx_http_request_t’ has no member named ‘zero_in_uri’
# make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] Error 1
# make[1]: Leaving directory `/root/nginx-0.8.54'
# make: *** [build] Error 2 #解决方法: #将/usr/local/nginx/soft-source/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c文件中以下代码删除或者是注释掉就可以了:大概在157行
# /* TODO: Win32 */
# if (r->zero_in_uri)
# {
# return NGX_DECLINED;
# }
# #在执行make的时候可能出现错误
# ../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c: 在函数‘esds_read’中:
# ../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:377:16: 错误: 变量‘stream_priority’被设定但未被使用 [-Werror=unused-but-set-variable]
# ../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:376:12: 错误: 变量‘stream_id’被设定但未被使用 [-Werror=unused-but-set-variable]
# ../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c: 在函数‘stsd_parse_vide’中:
# ../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:529:22: 错误: 变量‘level_indication’被设定但未被使用 [-Werror=unused-but-set-variable]
# ../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:528:22: 错误: 变量‘profile_compatibility’被设定但未被使用 [-Werror=unused-but-set-variable]
# ../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:527:22: 错误: 变量‘profile_indication’被设定但未被使用 [-Werror=unused-but-set-variable]
# ../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:526:22: 错误: 变量‘configuration_version’被设定但未被使用 [-Werror=unused-but-set-variable]
# cc1: all warnings being treated as errors
# make[1]: *** [objs/addon/src/mp4_reader.o] 错误 1 #解决方法:
# vi objs/Makefile (修改nginx-1.6.0/objs/Makefile文件, 去掉其中的"-Werror"), 然后就能够正常编译了.
# 然后再make就能过了。
vi objs/Makefile
make install #开放80和1935端口 关闭防火墙
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT 写入修改
/sbin/iptables -I INPUT -p tcp --dport 1935 -j ACCEPT 写入修改
/etc/init.d/iptables save 保存修改
#关闭防火墙
service iptables stop
#查看端口状态
/etc/init.d/iptables status
端口映射
映射流媒体服务器的 80 1935 22 端口到外网
#配置Nginx相关模块
进入到nginx文件夹!执行./nginx启动nginx 然后进行推送到nginx
rtmp://x.x.x.x/hls/ch68h
播放
rtmp://x.x.x.x.:1935/hls/ch68h
http://x.x.x.x/hls/ch68h.m3u8
以上内容为流媒体服务器的基本配置说明,根据项目不同可配置不同的配置文件,因Nginx配置文件为核心文件,所以暂不公开,如有需要的可与我沟通联系,此系统已经完善部署到几十个项目中,运行状况良好,同时也有少许bug,并在不断更新中.
【原创+史上最全】Nginx+ffmpeg实现流媒体直播点播系统的更多相关文章
- 收藏:视频网站(JavaEE+FFmpeg)/Nginx+ffmpeg实现流媒体直播点播系统
FFmpeg安装(windows环境)http://www.cnblogs.com/xiezhidong/p/6924775.html 最简单的视频网站(JavaEE+FFmpeg)http://bl ...
- 开源框架】Android之史上最全最简单最有用的第三方开源库收集整理,有助于快速开发
[原][开源框架]Android之史上最全最简单最有用的第三方开源库收集整理,有助于快速开发,欢迎各位... 时间 2015-01-05 10:08:18 我是程序猿,我为自己代言 原文 http: ...
- 史上最全的maven pom.xml文件教程详解
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- GitHub上史上最全的Android开源项目分类汇总 (转)
GitHub上史上最全的Android开源项目分类汇总 标签: github android 开源 | 发表时间:2014-11-23 23:00 | 作者:u013149325 分享到: 出处:ht ...
- .Net魔法堂:史上最全的ActiveX开发教程——ActiveX与JS间交互篇
一.前言 经过上几篇的学习,现在我们已经掌握了ActiveX的整个开发过程,但要发挥ActiveX的真正威力,必须依靠JS.下面一起来学习吧! 二.JS调用ActiveX方法 只需在UserContr ...
- .Net魔法堂:史上最全的ActiveX开发教程——自动更新、卸载篇
一.前言 B/S模式的特点之一,客户端版本升级相对简单.快捷,适合产品的快速迭代.而ActiveX组件的自动更新同样也继承了这一优点.下面我们一起来了解吧! 二.二话不说更新ActiveX 1. 设置 ...
- .Net魔法堂:史上最全的ActiveX开发教程——部署篇
一.前言 接<.Net魔法堂:史上最全的ActiveX开发教程——发布篇>,后我们继续来部署吧! 二. 挽起衣袖来部署 ActiveX的部署其实就是客户端安装ActiveX组件,对未签 ...
- .Net魔法堂:史上最全的ActiveX开发教程——发布篇
一. 前言 接着上一篇<.Net魔法堂:史上最全的ActiveX开发教程——开发篇>,本篇讲述如何发布我们的ActiveX. 二.废话少讲,马上看步骤! 1. 打包 C#开发的Activ ...
- .Net魔法堂:史上最全的ActiveX开发教程——开发篇
一.前言 在设计某移动内部自动化运维平台时,经综合考虑终端机性能和功能需求等因素后,决定采用B/S模式,并且浏览器通过ActiveX组件实现与服务器Agent作P2P的通讯.好处,整个平台以网页形式存 ...
随机推荐
- setTimeout 倒计时
<script type="text/javascript"> //设定倒数秒数 var t = 10; //显示倒数秒数 function showTime(){ t ...
- JAVA控制台版斗地主
一.核心思路: 1.首先分析流程: A>B>C>A>B>C>A>B>C 等于 while(true){ A>B>C } 然后完善细节 发牌 ...
- hdu1711kmp
Given two sequences of numbers : a11, a22, ...... , aNN, and b11, b22, ...... , bMM (1 <= M <= ...
- hdu3829最大独立集
The zoo have N cats and M dogs, today there are P children visiting the zoo, each child has a like-a ...
- Java的CLASSPATH
在JDK安装好后,要设置两个变量Path和Classpath,Path是操作系统要求的,这里不谈了,而classpath是Java虚拟机要求的这里做一个详细的解释. 一.classpath的作用 == ...
- 用ng-view创建单页APP
我们假设我们有一个单页面的程序,并且想为这个页面添加动画效果.点击某一个链接会将一个试图滑出,同时将另一个试图滑入. 我们将会使用: 使用 ngRoute 来为我们的页面路由 使用 ngAnimate ...
- SSH小结
工作有一段时间了,经常用SSH登录远程机器,但对原理一直不是很了解,所以查阅了一些资料,写个小结. 一. SSH是什么? SSH的全称是Secure Shell, 是一种"用来在不安全的网络 ...
- [UWP]实用的Shape指南
在UWP UI系统中,使用Shape是绘制2D图形最简单的方式,小到图标,大到图表都用到Shape的派生类,可以说有举足轻重的地位.幸运的是从Silverlight以来Shape基本没有什么大改动,简 ...
- 基于本地文件系统的LocalDB
零.前言 之前写一些小工具的时候,需要用到数据存储方面的技术,但是用数据库又觉得太大了,本地文件存储txt文件存储又不是很规范,于是乎想到了去编写一个简单的基于本地文件系统的数据存储库,暂且叫它loc ...
- MyBatis之简单了解Plugin
MyBatis的Configuration配置中有一个Plugin配置,根据其名可以解释为"插件",这个插件实质可以理解为"拦截器"."拦截器&quo ...