centos7+nginx+rtmp+ffmpeg搭建流媒体服务器
1.安装前需要的工具
#net-tool 查本地IP
#wget 下载安装包
#unzip 解压zip包
#gcc gcc-c++ perl 编译软件包用
yum install -y net-tools wget unzip gcc gcc-c++ perl
2. 将Centos的yum源更换为国内的阿里云源
#备份yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
#下载阿里源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#清空缓存
yum makecache
3. 安装nginx及rtmp
#切换的homme目录
cd /home
下载并解压pcre
#下载pcre包
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
#解压pcre包
tar -zxvf pcre-8.41.tar.gz
下载并解压zlib
#下载zlib包
wget http://www.zlib.net/zlib-1.2.11.tar.gz
#解压zlib包
tar -zxvf zlib-1.2..tar.gz
下载并安装openssl
#下载openssl包
wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1i.tar.gz
#解压openssl包
tar -zxvf openssl-1.0.1i.tar.gz
#切换到openssl里
cd openssl-1.0.1i
#生成配置文件 默认配置
./config
#编译程序
make
#安装程序
make install
下载并解压nginx-rtmp-model
#下载rtmp包
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
#解压下载包
unzip -o master.zip
#修改文件夹名
mv master nginx-rtmp-module
安装nginx
#下载
nginx wget http://nginx.org/download/nginx-1.12.2.tar.gz
#解压
nignx tar -zxvf nginx-1.12..tar.gz
#切换到nginx中
cd nginx-1.12.
#生成配置文件,将上述下载的文件配置到configure中
./configure --prefix=/usr/local/nginx --with-pcre=/home/pcre-8.41 --with-zlib=/home/zlib-1.2. --with-openssl=/home/openssl-1.0.1i --add-module=/home/nginx-rtmp-module
#编译程序
make
#安装程序
make install
#查看nginx模块
nginx -V
安装ffmpeg
#安装epel包
yum install -y epel-release
#导入签名
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-
#导入签名
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
#升级软件包
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
#更新软件包
yum update -y
#安装ffmpeg
yum install -y ffmpeg
#检查版本
ffmpeg -version
4. 修改配置运行服务
修改nginx配置
vi /usr/local/nginx/conf/nginx.conf
修改之后的配置
#user nobody;
worker_processes ;
#
##error_log logs/error.log;
##error_log logs/error.log notice;
##error_log logs/error.log info;
#
##pid logs/nginx.pid;
#
#
events {
worker_connections ;
}
#RTMP閰嶇疆
rtmp{
server{
listen ;
application myapp{
live on;
}
application hls{
live on;
hls on;
hls_path /tmp/hls;
}
}
}
#
http {
include mime.types;
default_type application/octet-stream;
#
##log_format main '$remote_addr - $remote_user [$time_local] "$request" '
## '$status $body_bytes_sent "$http_referer" '
## '"$http_user_agent" "$http_x_forwarded_for"';
#
access_log logs/access.log;
#
sendfile on;
##tcp_nopush on;
#
##keepalive_timeout ;
keepalive_timeout ;
#
gzip on;
#include /usr/local/nginx/conf.d/*.conf;
server {
listen 80;
server_name localhost;
#
##charset koi8-r;
#
##access_log logs/host.access.log main;
#
location / {
root html;
index index.html index.htm;
}
location /hls {
types{
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache;
}
##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;
}
}
}
#
## 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;
##}
#
#
## another virtual host using mix of IP-, name-, and port-based configurati
##error_page 404 /404.html;
#
## redirect server error pages to the static page /50x.html
##
执行nginx
/usr/local/nginx/sbin/nginx
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
测试功能
ffmpeg -re -i ychx.mp4 -vcodec copy -codec copy -f flv rtmp://192.168.199.145/hls/cctv
测试访问
视频切片保存位置:/tmp/hls/
m3u8视频访问地址:http://192.168.199.145/hls/cctv.m3u8
重启nginx
/usr/local/nginx/sbin/nginx -s reload
centos7+nginx+rtmp+ffmpeg搭建流媒体服务器的更多相关文章
- centos7+nginx+rtmp+ffmpeg搭建流媒体服务器(保存流目录与http目录不要随意配置,否则有权限问题)
搭建nginx-http-flv-module升级代替rtmp模块,详情:https://github.com/winshining/nginx-http-flv-module/blob/master ...
- (转)Nginx+rtmp+ffmpeg搭建流媒体服务器
(1)下载第三方扩展模块nginx-rtmp-module # mkdir module && cd module //创建一个存放模块的目录 # wget https://githu ...
- Linux-Nginx+rtmp+ffmpeg搭建流媒体服务器
Nginx+rtmp+ffmpeg搭建流媒体服务器 说明: nginx搭建流媒体服务需要用到 nginx-rtmp-module 模块 具体操作步骤: 安装nginx (1)下载第三方扩展模块ngin ...
- 使用nginx+nginx-rtmp-module+ffmpeg搭建流媒体服务器
参考: 1,使用nginx+nginx-rtmp-module+ffmpeg搭建流媒体服务器笔记(一)http://blog.csdn.net/xdwyyan/article/details/4319 ...
- nginx+nginx-rtmp-module+ffmpeg搭建流媒体服务器
参照网址: [1]http://blog.csdn.net/redstarofsleep/article/details/45092147 [2]HLS介绍:http://www.cnblogs.co ...
- 流媒体技术学习笔记之(一)nginx+nginx-rtmp-module+ffmpeg搭建流媒体服务器
参照网址: [1]http://blog.csdn.net/redstarofsleep/article/details/45092147 [2]HLS介绍:http://www.cnblogs.co ...
- nginx+nginx-rtmp-module+ffmpeg搭建流媒体服务器[转]
转 :http://redstarofsleep.iteye.com/blog/2123752 Nginx本身是一个非常出色的HTTP服务器,FFMPEG是非常好的音视频解决方案.这两个东西通过一个n ...
- Nginx+rtmp+ffmpeg 搭建推流服务器
1. 安装nginx服务器 1.1 clone $ brew tap denji/homebrew-nginx 1.2 安装 $ brew install nginx-full --with-rtmp ...
- Ubuntu下使用nginx和nginx-rtmp-module搭建流媒体服务器的正确姿势
之前在使用nginx和nginx-rtmp-module搭建流媒体服务器的时候遇到一个很尴尬的问题,就是在把nginx-rtmp-module模块添加到nginx中去的时候,我最开始采取的做法是先卸载 ...
随机推荐
- angularjs 与 UEditor开发,添加directive,保证加载顺序正常
'use strict'; angular.module('app.core').directive('ueditor', [function () { return { restrict: 'A', ...
- asp.net中处理程序调用HttpContext.Current.Session获取值出错
asp.net中处理程序调用System.Web.HttpContext.Current.Session获取Session时提示错误:未将对象引用设置到对象的实例. 解决办法:在处理程序文件类中实现I ...
- win10虚拟桌面;一不小心按错了突然只剩下桌面,启动的程序都没了
先说如何关闭虚拟桌面:ctrl+win+F4(万一你还没看到怎么关闭虚拟桌面,就创建并调整到虚拟桌面,会很懵的,因为你启动的所有程序全部都突然消失了,只剩下开机的桌面了): win10有个功能,虚拟桌 ...
- 本地Navicat连不上Linux虚拟机MySQL数据库问题
LinuxAndMySQL 版权声明:本文为博主原创文章,未经博主允许不得转载. 在Linux登录到MySQL数据:mysql -uroot -p 输入密码 切换到mysql数据库 mysql> ...
- Linux下修改tab建为4个空格
1.编辑 vim /etc/vim/vimrc 2.修改 set ts=4 set expandtab set autoindent 其实只要set ts=4 就ok了.
- Python 基础常用
.连接符: + .基本类型: [] {} () list set :无序,不重复的集合 数据初始化: a = set('a','b'); 或者 {'1'} #只能初始化空的集合: 相关函数: 添加数据 ...
- WeakHashMap<K,V> 中的弱引用
相信很多人对WeakHashMap并没有完全理解. WeakHashMap 持有的弱引用的 Key. 1. 弱引用的概念: 弱引用是用来描述非必需对象的,被弱引用关联的对象只能生存到下一次垃圾收集发生 ...
- ASP.NET 登录验证 ihttpmoudle
问题: 1.iis版本不同(IIS7.0,应用程序池采用的是集成模式,换成经典模式才起作用.) 在 IIS 7 以下的版本中,应用以下配置: <system.web> <httpMo ...
- 17. Letter Combinations of a Phone Number (backtracking)
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- 音频播放 音乐 MediaPlayer
MediaPlayer对象的生命周期如下: Idle 状态:当使用new()方法创建一个MediaPlayer对象或者调用了其reset()方法时,该MediaPlayer对象处于idle状态.这两种 ...