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. sql server快捷键添加

    工具--选项--键盘 sp_table_column_info p_helpindex sp_sql

  2. SpringBoot + sqlserver+mybatis

    一.maven引入 <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId&g ...

  3. MySQL Disk--MySQL磁盘问题排查

    存储问题排查 1.检测磁盘空间使用率 df -lh 注意系统目录的可用空间 2.检查磁盘inode使用 df -i 参考:https://www.cnblogs.com/gaogao67/p/1088 ...

  4. session有效期设置的两种方式

    /**session有效期设置的两种方式: * 1.代码设置:session.setMaxInactiveInterval(30);//单位:秒.30秒有效期,默认30分钟. * 2.web.xml中 ...

  5. 总结一下NDK crash排查步骤

    总结一下NDK crash排查步骤: 先在PC上跑通算法 用Visual Studio写算法的testbed,确保算法能跑通 抓log adb logcat -c; adb logcat > 1 ...

  6. ng add ng-zorro-antd 安装时报错 已经是管理员还需要权限Error: EPERM: operation not permitted, lstat 'C:\ngWorkspace\qd\node_modules\fsevents\node_modules'

    Error: EPERM: operation not permitted, lstat 'C:\ngWorkspace\qd\node_modules\fsevents\node_modules' ...

  7. VLAN实验4:利用单臂路由实现VLAN间路由

    单臂路由: 实验环境: 实验拓扑图: 实验编址: 实验步骤:1.创建VLAN并配置Access.Trunk接口. 我们在S2上创建VLAN10和VLAN20,并且吧链接PC1的E0/0/1和链接PC2 ...

  8. HTML&CSS基础-xHtml语法规范

    HTML&CSS基础-xHtml语法规范 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.html源码 <!DOCTYPE html> <html> ...

  9. Windows/Linux/Mac下安装mvn

    Step1: 去官网地址下载 http://maven.apache.org/download.cgi Step2: 解压并且移动到指定到目录下 Step3: 配置环境变量并使之生效 .bash_pr ...

  10. Hikari java数据库连接池实战

    环境InterlliJ2016.3  MySQL5.7.12 pom依赖: <dependency> <groupId>com.zaxxer</groupId> & ...