【问题标题】:Nginx RTMP with InstagramLive-PHP not working带有 InstagramLive-PHP 的 Nginx RTMP 无法正常工作
【发布时间】:2020-05-27 05:55:23
【问题描述】:

我想知道我是不是搞错了。所以我使用的两个库是:
1.https://github.com/arut/nginx-rtmp-module
2.https://github.com/JRoy/InstagramLive-PHP

Nginx RTMP 模块工作正常,我可以流式传输到从 Facebook 到 Twitch 的所有内容,但我似乎无法让它与 InstagramLive 库一起使用。我根据运行 InstagramLive 库后收到的流密钥和 URL 在 nginx.conf 文件中使用以下格式:

rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application live {
                        live on;
                        record off;
                        push rtmp://live-upload.instagram.com:80/rtmp/<key>;
                }
        }
}

但是,当我启动 OBS 流时,Instagram 帐户会显示其直播,但不会加载视频,并且一段时间后会出现提示超时的错误。我认为缩放/分辨率存在问题,如果有人可以提供帮助,我将不胜感激。

更新:

所以我将它流式传输到 Instagram,但直接流式传输时似乎存在缩放问题,因此尝试使用 ffmpeg 来解决。想出了下面的代码:

rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application live {
                    live on;
                    record off;

                    allow publish all;
                    allow play all;

                    push rtmp://127.0.0.1:1935/youtube;

                    exec ffmpeg -i rtmp://127.0.0.1:1935/live/$name -threads 1 -vcodec flv -acodec copy -s 1280x720 -f flv rtmp://127.0.0.1:1935/youtube;

                }

                application instagram {
                    live on;
                    record off;

                    push rtmp://live-upload.instagram.com:80/rtmp/KEY;
                }

                application youtube {
                    live on;
                    record off;

                    push rtmp://a.rtmp.youtube.com/live2/KEY;
                }

        }
}

现在不知何故,Instagram 视频再次无法加载,但 Youtube 或我包含的任何其他流都可以工作。

【问题讨论】:

    标签: php c++ nginx rtmp


    【解决方案1】:

    Instagram 使用安全 rtmp (rtmps://...) 但不幸的是 nginx-rtmp 模块不支持 rtmps。您可以使用第 3 方(例如您可以使用 stunnel)程序来完成这项工作:

    #nginx.conf
    application live{
        push  rtmp://127.0.0.1:19350/rtmp/{your-insta-stream-key}
    }
    

    并且在stunnel配置文件中:

    #stunnel.conf
    pid=/tmp/stunnel/stunnel.pid
    output = /tmp/stunnel/stunnel.log
    [insta-live]
    client = yes
    accept = 127.0.0.1:19350
    connect = live-upload.instagram.com:443
    

    别忘了在你的服务器上打开 19350 端口

    【讨论】:

      猜你喜欢
      • 2017-11-25
      • 1970-01-01
      • 1970-01-01
      • 2013-07-11
      • 1970-01-01
      • 2014-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多