windows下搭建ffmpeg + rtmp 流媒体服务器

网络上已经有nginx服务器搭建的文档,为什么我还要写呢?
啊哈!
因为每个人得环境不一样没问题不一样,所以写这篇文章仅作备忘用!
而且都不完整,百度出来都是同一篇文章...
所以这次我从头到位记录下这次的过程....
这...必将是一个漫长的过程...唉...
如果能帮上你,那就更好了!!
先看下这篇文章吧!

windows下搭建基于nginx的rtmp服务器 - zxw_tiantan的博客
http://blog.csdn.net/zxw_tiantan/article/details/53906253

下载 nginx 1.7.11.3 Gryphon.zip
附上最新版下载地址:
http://nginx-win.ecsds.eu/download/nginx 1.7.11.3 Gryphon.zip

下载完成后解压:
将解压后的目录名: nginx 1.7.11.3 Gryphon 改成: nginx-1.7.11.3-Gryphon

  1. 下载服务器状态检查程序 stat.xsl
    https://github.com/arut/nginx-rtmp-module/
    将nginx-rtmp-module-master.zip解压后复制到目录:nginx-1.7.11.3-Gryphon下,
    保证stat.xls的目录为:nginx-1.7.11.3-Gryphon\nginx-rtmp-module\stat.xsl
  2. 配置文件 conf\nginx-win.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;
}

http {
#include /nginx/conf/naxsi_core.rules;
include mime.types;
default_type application/octet-stream;
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root nginx-rtmp-module/;
}
location /control {
rtmp_control all;
}

#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"';

#access_log  logs/access.log  main;

# loadbalancing PHP

upstream myLoadBalancer {

server 127.0.0.1:9001 weight=1 fail_timeout=5;

server 127.0.0.1:9002 weight=1 fail_timeout=5;

server 127.0.0.1:9003 weight=1 fail_timeout=5;

server 127.0.0.1:9004 weight=1 fail_timeout=5;

server 127.0.0.1:9005 weight=1 fail_timeout=5;

server 127.0.0.1:9006 weight=1 fail_timeout=5;

server 127.0.0.1:9007 weight=1 fail_timeout=5;

server 127.0.0.1:9008 weight=1 fail_timeout=5;

server 127.0.0.1:9009 weight=1 fail_timeout=5;

server 127.0.0.1:9010 weight=1 fail_timeout=5;

least_conn;

}

sendfile        off;
#tcp_nopush     on;

server_names_hash_bucket_size 128;

Start: Timeouts

client_body_timeout   10;
client_header_timeout 10;
keepalive_timeout     30;
send_timeout          10;
keepalive_requests    10;

End: Timeouts

#gzip  on;

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    ## Caching Static Files, put before first location
    #location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
    #    expires 14d;
    #    add_header Vary Accept-Encoding;
    #}

For Naxsi remove the single # line for learn mode, or the ## lines for full WAF mode

    location / {
        #include    /nginx/conf/mysite.rules; # see also http block naxsi include line
        ##SecRulesEnabled;
          ##DeniedUrl "/RequestDenied";
          ##CheckRule "$SQL >= 8" BLOCK;
          ##CheckRule "$RFI >= 8" BLOCK;
          ##CheckRule "$TRAVERSAL >= 4" BLOCK;
          ##CheckRule "$XSS >= 8" BLOCK;
        root   html;
        index  index.html index.htm;
    }

For Naxsi remove the ## lines for full WAF mode, redirect location block used by naxsi

    ##location /RequestDenied {
    ##    return 412;
    ##}

Lua examples !

location /robots.txt {

rewrite_by_lua '

if ngx.var.http_host ~= "localhost" then

return ngx.exec("/robots_disallow.txt");

end

';

}

    #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; # single backend process
    #    fastcgi_pass   myLoadBalancer; # or multiple, see example above
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  $document_root$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       8000;
#    listen       somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}


# HTTPS server
#
#server {
#    listen       443 ssl spdy;
#    server_name  localhost;

#    ssl                  on;
#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_timeout  5m;

#    ssl_prefer_server_ciphers On;
#    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#    ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:ECDH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!eNULL:!MD5:!DSS:!EXP:!ADH:!LOW:!MEDIUM;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}

}

rtmp {

server {
listen 1935;

#直播流配置
  application rtmplive {
      live on;
  #为 rtmp 引擎设置最大连接数。默认为 off
  max_connections 1024;

   }


  application hls{

      live on;
      hls on;
      hls_path H:\phpStudy\WWW\hls;
      hls_fragment 1s;
  }

}
}

···

好了!rtmp服务器搭建完成了!

  1. 启动服务器进入windows的cmd;
> cd nginx-1.7.11.3-Gryphon
> nginx.exe -c conf\nginx-win-rtmp.conf

啊!!!!起不来~~rtmp加载不进去。。
继续百度
该安装ffmpeg了!
来吧!

最新下载直连:https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20161230-6993bb4-win64-static.zip
官网:https://ffmpeg.zeranoe.com/builds/

握草!!官网下载速度太慢!!等了好久!
附上百度盘的链接吧:http://pan.baidu.com/s/1eSifLFc

好勒!现在开始安装:
首先要解压对不对?
解压完成后复制里面的内容到C盘根目录下(需要新建一个名为ffmpeg的文件夹哦!)
这样的:

123.png

然后呢?
我们需要把ffmpeg命令添加到全局哦!
右键点击我的电脑选择属性找到:

456.png
789.png

选择环境变量

010.png

012.png

写漏了。。。目录应该是:c:\ffmpeg\bin
啊哈!到这就设置完成了!来试试吧!!
出现这个就说明对了哦!

013.png

那现在试试推流吧!

ffmpeg推流命令:

ffmpeg -re -i E:\QQ空间\我要找一个对象.mpg -vcodec libx264 -acodec aac -f flv rtmp://localhost:1935/rtmplive/home

哎呀!推流时报错了。。rtmp服务器没有启动成功..
太晚了 睡觉 明天继续。。。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 151,511评论 1 330
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 64,495评论 1 273
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 101,595评论 0 225
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 42,558评论 0 190
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 50,715评论 3 270
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 39,672评论 1 192
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,112评论 2 291
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 29,837评论 0 181
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 33,417评论 0 228
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 29,928评论 2 232
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,316评论 1 242
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 27,773评论 2 234
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,253评论 3 220
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 25,827评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,440评论 0 180
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 34,523评论 2 249
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 34,583评论 2 249

推荐阅读更多精彩内容