Windows:

1、下载文件:

链接:https://pan.baidu.com/s/1c2LmIHHw-dwLOlRN6iTIMg
提取码:g7sj
2、解压文件:

解压到nginx-1.7.11.3-Gryphon

3、进入windows的cmd;

> cd nginx-1.7.11.3-Gryphon    //进入nginx的目录

> nginx.exe -c conf\nginx-win-rtmp.conf   //运行rtmp配置文件

注意:此时命令行会一直处于执行中 不用理会  也不要关闭

测试:浏览器输入localhost:80  ,查看是否配置nginx启动成功!
4、推流:

ffmpeg -re -i 123.mp4 -vcodec libx264 -acodec aac -f flv rtmp://你的ip地址:1935/live/home

5、拉流:

电脑打开vlc播放器    输入地址:rtmp://你的ip地址:1935/live/home

 Linux:

1、安装工具:

#gcc gcc-c++ perl 编译软件包用

yum install -y net-tools wget unzip gcc gcc-c++ perl

2、安装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.11.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.2.tar.gz
#切换到nginx中
cd nginx-1.12.2
#生成配置文件,将上述下载的文件配置到configure中
./configure --prefix=/usr/local/nginx --with-pcre=/home/pcre-8.41 --with-zlib=/home/zlib-1.2.11 --with-openssl=/home/openssl-1.0.1i --add-module=/home/nginx-rtmp-module
#编译程序
make
#安装程序
make install
#创建全局命令
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
#查看nginx模块 nginx -V
安装FFmpeg:
安装ffmpeg时需要提前安装yasm插件:
cd /home
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3..tar.gz
tar -xvf yasm-1.3..tar.gz
cd yasm-1.3./
./configure && make && make install

开始安装ffmpeg:
cd /home
wget http://www.ffmpeg.org/releases/ffmpeg-3.4.tar.gz
tar -xvf ffmpeg-3.4.tar.gz
cd ffmpeg-3.4/
./configure && make && make install 编译成功后测试:
ffmpeg --help

修改nginx配置:

新建配置文件:
vi /usr/local/nginx/conf/nginx-rtmp.conf
输入内容:
#user nobody;
worker_processes 1;
#
##error_log logs/error.log;
##error_log logs/error.log notice;
##error_log logs/error.log info;
#
##pid logs/nginx.pid;
#
#
events {
worker_connections 1024;
}
#RTMP閰嶇疆
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;
#
##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 0;
keepalive_timeout 65;
#
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 123.mp4 -vcodec copy -codec copy -f flv rtmp://你的ip/hls/cctv

测试访问

视频切片保存位置:/tmp/hls/
m3u8视频访问地址:http://你的ip/hls/cctv.m3u8

 重启nginx

/usr/local/nginx/sbin/nginx -s reload

用FFmpeg+nginx+rtmp搭建环境实现推流的更多相关文章

  1. 使用 ffmpeg nginx rtmp 搭建实时流处理平台

    环境: ubuntu 16.04 问题引入: 使用 opencv 获取摄像头数据帧, 进行处理之后(如进行 keypoint 识别), 将 opencv 中图像的 Mat类型转化为 ffmpeg 的 ...

  2. iOS开发之利用IJKPlayer+nginx+rtmp搭建直播的推流和拉流

    最近项目中想实现直播的功能,所以研究了一段时间的直播功能,当然也是在别人的基础上不断的学习实现的,所以记录一下,希望对大家有所帮助. 直播拉流功能: 这里使用了开源的IJKPlayer第三框架,ijk ...

  3. 三、Windows下用FFmpeg+nginx+rtmp搭建直播环境 实现推流、拉流

    一.环境 1.开发环境:windows 2.开发工具:FFmpeg.nginx.nginx-rmtp-module (链接:https://pan.baidu.com/s/119d2GeMzddas_ ...

  4. nginx + rtmp 搭建流媒体服务器

    一.安装nginx服务器 1.路径说明: 路径:/usr/local/src 2.下载nginx-rtmp-module (我这里的目录是在/usr/local/src/下面) cd /usr/loc ...

  5. Ubuntu中使用Nginx+rtmp搭建流媒体直播服务

    一.背景 本篇文章是继上一篇文章<Ubuntu中使用Nginx+rtmp模块搭建流媒体视频点播服务>文章而写,在上一篇文章中我们搭建了一个点播服务器,在此基础上我们再搭建一个直播服务器, ...

  6. ffmpeg处理rtmp/文件/rtsp的推流和拉流

    ffmpeg处理rtmp/文件/rtsp的推流和拉流   本demo演示了利用ffmpeg从服务器拉流或本地文件读取流,更改流url或文件类型名称发送回服务器或存到本地的作用. 由于本程序只写了3个小 ...

  7. Mac上搭建直播服务器Nginx+rtmp,实现手机推流、拉流

    转载自http://www.cnblogs.com/jys509/p/5649066.html 简介 nginx是非常优秀的开源服务器,用它来做hls或者rtmp流媒体服务器是非常不错的选择,本人在网 ...

  8. windows下搭建ffmpeg+nginx+rtmp-module搭建实时视频环境

    下载ffmpeg的Windows静态版: https://ffmpeg.zeranoe.com/builds/win64/static/下载nginx-rtmp-windows版:https://gi ...

  9. PHP入门-Window 下利用Nginx+PHP 搭建环境

    前言 最近公司有个PHP项目需要开发维护,之前一直都是跟着巨硬混的,现在要接触PHP项目.学习一门新语言之前,先搭建好环境吧,鉴于公司项目是基于php 7.1.33 版本的,所以以下我使用的都是基于这 ...

随机推荐

  1. 黑马oracle_day01:02.oracle的基本操作

    01.oracle体系结构 02.oracle的基本操作 03.oracle的查询 04.oracle对象 05.oracle编程 02.oracle的基本操作 PLSQL中文乱码问题解决1.查看服务 ...

  2. mysql第六篇 : MySQL索引原理与慢查询优化

    浏览目录 一.索引介绍 二.索引方法 三.索引类型 四.聚合索引和辅助索引 五.测试索引 六.正确使用索引 七.组合索引 八.注意事项 九.查询计划 十.慢日志查询 十一.大数据量分页优化 一.索引介 ...

  3. office(CVE-2012-0158)漏洞分析报告

    2019/9/12 1.漏洞复现 ①发现崩溃 ②找到漏洞所在的函数,下断点,重新跑起来,单步调试,找到栈被改写的地方 ③分析该函数 把MSCOMCTL拖入IDA,查看该函数代码 ④查看调用栈,回溯. ...

  4. UVA - 10570 Meeting with Aliens(外星人聚会)(暴力枚举)

    题意:输入1~n的一个排列(3<=n<=500),每次可以交换两个整数.用最少的交换次数把排列变成1~n的一个环状序列. 分析:正序反序皆可.枚举每一个起点,求最少交换次数,取最小值. 求 ...

  5. 2018出炉50道iOS面试题

    基础: 1.如何令自己所写的对象具有拷贝功能? 若想令自己所写的对象具有拷贝功能,则需实现 NSCopying 协议.如果自定义的对象分为可变版本与不可变版本,那么就要同时实现 NSCopying与 ...

  6. 一条命令解决:No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

    1.找到目录D:\android\Sdk\ndk-bundle\toolchains.(根据自己的安装路径找到) 2.该路径下打开终端执行ln -sf aarch64-linux-android-4. ...

  7. 线性数据结构案例1 —— 单向链表中获取倒数k个节点

    一.介绍  先遍历整个链表获取链表长度length,然后通过 (length-index) 方式得到我们想要节点在链表中的位置. 二.代码 public Node findLastIndexNode( ...

  8. cmake的find_package()简单总结

    遇到的问题 find_package(lzb)出现错误如下: CMake Warning at CMakeLists.txt:37 (find_package): By not providing & ...

  9. 关于GAN的一些笔记

    目录 1 Divergence 1.1 Kullback–Leibler divergence 1.2 Jensen–Shannon divergence 1.3 Wasserstein distan ...

  10. 为什么 execute(`echo 中文`) 输出中文源码?

    为什么 execute(echo 中文) 输出中文源码? import win.ui; /*DSG{{*/ var winform = win.form(text="管道演示";r ...