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搭建流媒体服务器的更多相关文章

  1. centos7+nginx+rtmp+ffmpeg搭建流媒体服务器(保存流目录与http目录不要随意配置,否则有权限问题)

    搭建nginx-http-flv-module升级代替rtmp模块,详情:https://github.com/winshining/nginx-http-flv-module/blob/master ...

  2. (转)Nginx+rtmp+ffmpeg搭建流媒体服务器

    (1)下载第三方扩展模块nginx-rtmp-module # mkdir module && cd module //创建一个存放模块的目录 # wget https://githu ...

  3. Linux-Nginx+rtmp+ffmpeg搭建流媒体服务器

    Nginx+rtmp+ffmpeg搭建流媒体服务器 说明: nginx搭建流媒体服务需要用到 nginx-rtmp-module 模块 具体操作步骤: 安装nginx (1)下载第三方扩展模块ngin ...

  4. 使用nginx+nginx-rtmp-module+ffmpeg搭建流媒体服务器

    参考: 1,使用nginx+nginx-rtmp-module+ffmpeg搭建流媒体服务器笔记(一)http://blog.csdn.net/xdwyyan/article/details/4319 ...

  5. nginx+nginx-rtmp-module+ffmpeg搭建流媒体服务器

    参照网址: [1]http://blog.csdn.net/redstarofsleep/article/details/45092147 [2]HLS介绍:http://www.cnblogs.co ...

  6. 流媒体技术学习笔记之(一)nginx+nginx-rtmp-module+ffmpeg搭建流媒体服务器

    参照网址: [1]http://blog.csdn.net/redstarofsleep/article/details/45092147 [2]HLS介绍:http://www.cnblogs.co ...

  7. nginx+nginx-rtmp-module+ffmpeg搭建流媒体服务器[转]

    转 :http://redstarofsleep.iteye.com/blog/2123752 Nginx本身是一个非常出色的HTTP服务器,FFMPEG是非常好的音视频解决方案.这两个东西通过一个n ...

  8. Nginx+rtmp+ffmpeg 搭建推流服务器

    1. 安装nginx服务器 1.1 clone $ brew tap denji/homebrew-nginx 1.2 安装 $ brew install nginx-full --with-rtmp ...

  9. Ubuntu下使用nginx和nginx-rtmp-module搭建流媒体服务器的正确姿势

    之前在使用nginx和nginx-rtmp-module搭建流媒体服务器的时候遇到一个很尴尬的问题,就是在把nginx-rtmp-module模块添加到nginx中去的时候,我最开始采取的做法是先卸载 ...

随机推荐

  1. php缩小png图片时,不损失透明色的办法

    做站点时,通常要将图片缩小成合适的尺寸,jpg图片缩小比较容易,png图片如果带了透明色的话,按照jpg的方式来缩小的话,就会造成透明色损失.那么如何处理,才能保存透明色呢? 主要是利用gd库的两个方 ...

  2. 组播协议——IGMP v2报文头介绍

    TYPE:占一个字节,其值有:0x16.0x12.0x17三种类型. Max Resp Time:最大响应时间,占一个字节. Checksum:校验和,占两个字节. Group address:组播地 ...

  3. oracle数据表中的中文变问号

    先查询一下select userenv('language') from dual;查看oracle字符集, $ sqlplus /nolog SQL> connect sys/oracle a ...

  4. [译]CQRS介绍

    以下内容均为看完原文后自己的理解.并非一字一句翻译,会尽量保持原文意思. 什么是 CQRS: CQRS 意思就是命令查询职责分离(Command Query Responsibility Segreg ...

  5. iOS Dev (25) 解决“The executable was signed with invalid entitlements.”问题

    2014-01-10 10:34 5240人阅读 评论(1) 收藏 举报   目录(?)[+]   iOS Dev (25) 解决“The executable was signed with inv ...

  6. debug.keystare找不到的解决办法[转]

    重装系统之后,丢失了debug.keystore,找了很久都没有找到,根据网上所讲的只要重新运行一个android项目;就会在avd中生成一个新的debug.keystroe,此法也没解决,索性直接重 ...

  7. PowerDesigner 逆向工程

    原文地址:https://www.cnblogs.com/feilong3540717/archive/2011/11/18/2254040.html PowserDesigner 的打开路径:Fil ...

  8. tensorflow 高级api使用分布式之配置

    """Constructor. Sets the properties `cluster_spec`, `is_chief`, `master` (if `None` i ...

  9. kafka 删除topic

    两种方法: 一.修改配置文件server.properties 添加如下配置: delete.topic.enable=true 说明:官方给的文档说明“Enables delete topic. D ...

  10. ReactCSSTransitionGroup

    [ReactCSSTransitionGroup] ReactCSSTransitionGroup is a high-level API based on ReactTransitionGroup  ...