目录简介和安装
配置
OBS推流
运行
拉流
完成
简介和安装
Nginx 本身是一个非常出色的HTTP服务器,OBS (Open Broadcaster Software) 是一个免费且开源的,全平台支持的视频录制和直播软件。这两个东西通过一个nginx的模块nginx-rtmp-module组合在一起,即可以搭建一个功能流媒体服务器。这个流媒体服务器可以支持RTMP和HLS(Live Http Stream)。
FFmpeg也是一个非常优秀的音视频解决软件。但OBS的界面更加友好,且支持屏幕捕获,所以我选择OBS。其实是因为FFmpeg没有GUI界面,所以我懒得再去研究它。
关于Nginx的安装,可以参考这里。在Linux端的Nginx与RTMP模块的安装,可以参考这里。RTMP模块的Github地址在这里,你可以在这里看到更为详尽的使用说明。
作者在Windows环境下搭建服务器,并且仅仅以最简单的方式实现作者需要的功能。
配置
假定你已经安装好了Nginx和RTMP插件,现在是使用它的时候了。
首先,定义一个Nginx的配置文件nginx-win-rmtp.conf。
展开查看范例
#user nobody;
# multiple workers works !
worker_processes 2;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 8192;
# max value 32768, nginx recycling connections+registry optimization =
# this.value * 20 = max concurrent connections currently tested with one worker
# C1000K should be possible depending there is enough ram/cpu power
# multi_accept on;
}
rtmp {
server {
listen 1935;
chunk_size 4000;
application live {
live on;
}
}
}
http {
#include /nginx/conf/naxsi_core.rules;
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr:$remote_port - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';