php - Nginx RTMP 不录制

标签 php linux nginx record rtmp

我已经在由 DigitalOcean 托管的 ubuntu linux 中设置了 Nginx RTMP。目前在我的桌面上以本地主机模式运行我的 laravel web 应用程序。直播似乎一切正常。我正在使用本地主机 JWPlayer 和 Open Broadcaster Software (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;
                    }
            }
    }
}

开始录制:

<a href="http://server.com/control/record/start?app=live&name=key&rec=rec1" target="_blank">Start rec1</a>

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;
    #}
}

顺便说一下

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

最佳答案

您可以在 shell 脚本 nginx conf 中运行。先检查权限:

chown -R nobody:nogroup foldername

chmod -R 700 foldername

外壳脚本:

ffmpeg -v error -y -i "$1" -vcodec libx264 -acodec aac -f mp4 -movflags +faststart "/tmp/recordings/$2.mp4"

aws s3 cp "/tmp/recordings/$basname.mp4" "s3://bucketname/"

exec_record_done bash -c "/home/ubuntu/script/record.sh $path $basname";

关于php - Nginx RTMP 不录制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28302533/

相关文章:

php - Laravel Scout和Elastic Search在测试中不起作用

linux - 为什么 xclip -loop 1 停止工作?

performance - 仅使用 nginx 服务器,EC2 微型实例应该能够处理多少用户?

php - 如何使用来自 Analytics API 的数据将相同数量的行传递给 Google Charts API

php - 获取变量中的“真”

c++ - linux下无法打开串口

linux - 在开始时运行 Python 脚本

ubuntu - 恢复完整的nginx配置

nginx 入口 : Too many redirects when force-ssl is enabled

php - 在发送到服务器之前如何操作表单数据?