Windows10环境下 Nginx+ffmpeg自搭服务器制作RTMP直播流
学习笔记

所需条件:

nginx-rtmp-module(带rtmp模块) ,链接:https://link.jianshu.com/?t=http%3A%2F%2Fnginx-win.ecsds.eu%2Fdownload%2Fnginx%201.7.11.3%20Gryphon.zip

ffmpeg,链接:https://pan.baidu.com/s/1XItEYzDjpGrkAUinBwQTUw
提取码:o0fg

VLC播放器,https://www.videolan.org/

安装nginx:
1、下载后,直接解压到自己想解压的地方,然后进入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 ;
}
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 main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout ;
keepalive_timeout ;
#gzip on;
server {
listen ;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page /.html;
# redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# 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 configuration
#
#server {
# listen ;
# listen somename:;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }
rtmp_auto_push on;
rtmp {
server {
listen ;
application myapp {
live on;
}
}
}

#主要上上面这两段rtmp模块代码,在代码的最后加上一个rtmp模块

2、然后,启动nginx,nginx命令:
启动:strat nginx
关闭:nginx -s stop
重启:nginx -s reload
注意:修改完配置必须重启
注意:如果出现错误,说nginx.pid不存在,则要在logs目录下创建nginx.pid,error.log不存在则创建error.log

3、启动后,发现命令行并没有什么显示,这时打开localhost:8888,看到nginx的页面就发现nginx已经启动
注意:端口号在nginx.conf的LISTEN配置

安装ffmpeg:
1、解压到自己喜欢的地方
2、添加电脑环境变量,这样就可以全局使用ffmpeg命令,进入环境变量PATH,进行编辑,加入如:D:/ffmpeg/bin,即可
3、测试是否成功,cmd命令行下输入ffmpeg即可查看

安装VLC:
到官网下载即可(用于播放流直播)

进行推流:
进入一个具有测试视频test.mp4的文件夹,在cmd命令行下进行推流,
ffmpeg -re -i test.mp4 -vcodec libx264 -acodec aac -f flv rtmp://localhost:1935/myapp/pc

解释:
1、myapp为application的名字,由nginx的conf中定义
2、pc自定义,由推流方确定,组成一个地址rtmp://localhost:1935/myapp/pc
3、-vcodec libx264 代表264视频编码
4、-acodec aac -f flv 代表aac音频编码

查看直播源:
在VLC的媒体/打开网络串流/网络,输入推流的地址:rtmp://localhost:1935/myapp/pc,就可以看到直播啦

这篇博客主要用来记录自己的笔记,还有给一些需要参考的人提供下,互相学习,如有不对或者不好的地方,大家可以提出批评和建议,o(∩_∩)o

最后感谢提供参考的博客和博主:
Silence潇湘夜雨
https://www.jianshu.com/p/59b558bac8a7

Windows10环境下 Nginx+ffmpeg自搭服务器制作RTMP直播流的更多相关文章

  1. Windows10环境下使用VisualSVN server搭建SVN服务器

    参考: Windows10环境下使用VisualSVN server搭建SVN服务器 要搭建个svn用.之前自己的服务器用的乌龟.后来用了这个VisualSVN server. 具体教程见上链接.暂无 ...

  2. Android 环境下编译FFmpeg

    Android 环境下编译FFmpeg 开发环境:Ubuntu 12.04.2 LTS , android-sdk-linux, android-ndk-r8e 一 .X264 编译 1.    X2 ...

  3. 搭建windows环境下(nginx+mysql+php)开发环境

    搭建windows环境下(nginx+mysql+php)开发环境   1. 所需准备应用程序包        1.1 nginx 程序包nginx-1.0.4.zip或其他版本(下载地址: http ...

  4. tensorflow安装过程cpu版-(windows10环境下)---亲试可行方案

    tensorflow安装过程cpu版-(windows10环境下)---亲试可行方案   一, 前言:本次安装tensorflow是基于Python的,安装Python的过程不做说明 二, 安装环境: ...

  5. Windows环境下使用bitvise架构sftp服务器

    Windows环境下使用Bitvise架构sftp服务器 Bitvise分成Bitvise ssh server和Bitvise ssh client 0 说明:文档暂时只使用Bitvise工具做搭建 ...

  6. aarch64环境下,搭建并配置服务器tomcat:

    aarch64环境下,搭建并配置服务器tomcat: 环境说明及下载相关文件: 1. ARM环境:aarch64开发板 2.JDK安装包: jdk-8u231-linux-arm64-vfp-hflt ...

  7. windows10环境下QtCreator中出现skipping incompatible xxx when searching for xxx 问题解决办法

    windows10环境下QtCreator中出现skipping incompatible xxx when searching for xxx 我再QtCreator中想导入一个外部库时,他提示不匹 ...

  8. 搭建rtmp直播流服务之1:使用nginx搭建rtmp直播流服务器(nginx-rtmp模块的安装以及rtmp直播流配置)

    欢迎大家积极开心的加入讨论群 群号:371249677 (点击这里进群) 一.方案简要 首先通过对开发方案的仔细研究(实时监控.流媒体.直播流方案的数据源-->协议转换-->服务器--&g ...

  9. nginx开发(四)调用ffmpeg,搭建rtmp直播流。

    1: 修改conf文件,配置rtmp直播 打开usr/local/nginx/conf/nginx.conf,添加红色内容: rtmp {#rtmp点播配置    server {        li ...

随机推荐

  1. 关于何时执行shiro AuthorizingRealm 里的 doGetAuthenticationInfo与doGetAuthorizationInfo

    1.doGetAuthenticationInfo执行时机如下 当调用Subject currentUser = SecurityUtils.getSubject(); currentUser.log ...

  2. H3C WLAN相关组织和标准

  3. vue 父组件与子组件的三生三世

    父组件和子组件相互传值:https://www.cnblogs.com/cxscode/p/11187989.html vue父组件触发子组件方法:https://www.cnblogs.com/cx ...

  4. 【转载】.Net 大型分布式基础服务架构横向演变概述

    原文:https://www.cnblogs.com/chejiangyi/p/5220217.html 一. 业务背景 构建具备高可用,高扩展性,高性能,能承载高并发,大流量的分布式电子商务平台,支 ...

  5. 使用flask搭建微信公众号:实现签到功能

    终于到了实战阶段.用微信公众号实现一个简单的签到功能. 前情提要: 微信公众号token验证失败 使用flask搭建微信公众号:完成token的验证 使用flask搭建微信公众号:接收与回复消息 程序 ...

  6. springmvc的控制器是不是单例模式,如果是,有什么问题,怎么解决?

    默认情况下是单例模式, 在多线程进行访问的时候,有线程安全问题. 但是不建议使用同步,因为会影响性能. 解决方案,是在控制器里面不能写成员变量. 为什么设计成单例设计模式? 1.性能(不用每次请求都创 ...

  7. 35 Top Open Source Companies

    https://www.datamation.com/open-source/35-top-open-source-companies-1.html If you think of open sour ...

  8. python - django 控制台输出 sql 语句

    只需要在 settings.py 文件中加入以下配置即可. LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers ...

  9. invoke和begininvoke 区别

    一直对invoke和begininvoke的使用和概念比较混乱,这两天看了些资料,对这两个的用法和原理有了些新的认识和理解. 首先说下,invoke和begininvoke的使用有两种情况: 1. c ...

  10. 05-Flutter移动电商实战-dio基础_引入和简单的Get请求

    这篇开始我们学习Dart第三方Http请求库dio,这是国人开源的一个项目,也是国内用的最广泛的Dart Http请求库. 1.dio介绍和引入 dio是一个强大的Dart Http请求库,支持Res ...