【问题标题】:ffmpeg exec command not running in nginx rtmpffmpeg exec命令未在nginx rtmp中运行
【发布时间】:2017-02-22 10:33:04
【问题描述】:

我正在使用 nginx 和 rtmp 模块来流式传输实时 hls 和 mpeg-dash。 这是我在 nginx .conf 中的 rtmp 命令

rtmp {
server {
    listen 1936;


    application mypull {
    live on ;
    meta copy;
    allow play all;

    pull rtmp://184.72.239.149/vod/BigBuckBunny_115k.mov name=test live=1;


    exec_push   /usr/bin/ffmpeg -re -i rtmp://localhost:1936/mypull/$name -vcodec libx264 -acodec libmp3lame -f flv rtmp://localhost:1936/hls/$name;


}


application dash {
        live on;
        dash on;
        dash_path /tmp/dash;
        dash_nested on;
        dash_fragment 5s;
        dash_playlist_length 30s;
    }
     application hls {
        live on;
        hls on;
    hls_playlist_length 30s;
    hls_fragment 5s;
        hls_path /tmp/hls;
    }
}
}

但它没有播放。似乎 ffmpeg 命令甚至没有运行。并且 hls 和 dash 文件夹是空的。有人可以帮我吗?

【问题讨论】:

  • 用实际的streamID替换变量后,您的ffmpeg命令是否可以从命令行工作?
  • 这是真实的id,我的nginx.conf就是这样的。它不会创建任何输出。 @GergelyLukacsy
  • 没有。流 ID 被替换为 $name 变量。当您打开流时,URL 如下所示:rtmp://server.com:1935/mypull/12345 其中12345 是您的流 ID。我认为在这种情况下你可以替换任何东西,所以试试这是你的控制台:ffmpeg -re -i rtmp://localhost:1936/mypull/123 -vcodec libx264 -acodec libmp3lame -f flv rtmp://localhost:1936/hls/123 另外,确保在防火墙设置中打开端口。为什么 RTMP 使用 1936?默认值为 1935。
  • 还有,系统的哪个部分不工作?您在这里列出了三个不同的应用程序。实时播放? HLS?硬盘驱动器?
  • 我的流 id 是测试。我在 name=test 中声明了它,并且我还打开了端口(1936 年)。我的 hls 应用程序不工作,似乎它没有制作片段和 m3u8 文件,因为当我尝试在在线播放器上播放它时,使用 F12 它为 test.m3u8 @GergelyLukacsy 提供 404

标签: nginx ffmpeg rtmp http-live-streaming mpeg-dash


【解决方案1】:

编辑您的 nginx.conf 文件并放入第一行:

user  root;

这将以 root 身份运行您的命令

【讨论】:

    【解决方案2】:

    将 ffmpeg 命令放入 bash 脚本中。例如,我的 bash 脚本名为 ff.sh,并存储在文件夹 /files

    将整个 ffmpeg 命令放入脚本中,并使其可执行:

    chmod +x /files/ff.sh
    

    exec_push nginx.conf 中的脚本

    application origin {
    live on;
     exec_push /files/ff.sh;
    }
    

    您可能会发现这对您有用。

    【讨论】:

      【解决方案3】:

      确保运行 nginx 的用户可以执行命令。通常它没有分配外壳。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-01-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-10-09
        • 1970-01-01
        • 2017-01-30
        相关资源
        最近更新 更多