Nginx RTMP 不录音

And*_*ner 7 php linux record nginx rtmp

我已经在 DigitalOcean 托管的 ubuntu linux 中设置了 Nginx RTMP。目前在我的桌面上以 localhost 模式运行我的 laravel Web 应用程序。直播似乎一切正常。我正在使用本地主机 JWPlayer 和开放广播软件(OBS)进行实时流媒体测试。有用。但是每当我需要将流媒体视频录制到linux目录(/var/www)时,在我点击OBS中的停止流媒体按钮后,似乎什么也没有发生,也没有任何错误。

我不知道录音是如何进行的,我尝试录制手册,上面有链接。我点击开始录制,它出现 /var/rec/{mystream}.flv

此手动版本的录制链接嵌入在 Laravel 网站中:

rtmp {
    server {
            listen 1935;
            chunk_size 4096;

            application live {

                    live on;

                    recorder rec1 {
                        record all manual;
                        record_suffix all.flv;
                        record_path /var/rec;
                        record_unique on;
                    }
            }
    }
}
Run Code Online (Sandbox Code Playgroud)

开始录音:

<a href="http://server.com/control/record/start?app=live&name=key&rec=rec1" target="_blank">Start rec1</a>
Run Code Online (Sandbox Code Playgroud)

http 的 nginx 配置:

access_log logs/rtmp_access.log;
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  0;
keepalive_timeout  65;

#gzip  on;

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 /stat {
        rtmp_stat all;
        rtmp_stat_stylesheet stat.xsl;  
    }

    location /stat.xsl {
        root /var/www/;
    }


    location /control {
        rtmp_control all;
    }


   #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;
    #}
}
Run Code Online (Sandbox Code Playgroud)

顺便一提

计划 B:我计划将录制的流文件存储到 Amazon AWS s3。任何人都知道如何使用 RTMP Nginx 而不是使用 Wowza Amazon 来做到这一点。

bhh*_*988 0

您应该检查您尝试记录到的目录(在您的情况下为 /var/rec )的权限。Nginx,即使使用 sudo 启动,默认情况下也会以用户“nobody”生成工作进程。您还可以尝试将工作进程生成的用户更改为:https://serverfault.com/a/534512/102045