在 nginx 中运行 bash 文件(.sh)

问题描述 投票:0回答:1

我想在 nginx 服务器上运行 bash 文件。该服务器接收 rtmp 流,bash 文件使用 ffmpeg 将其转换为不同质量。该文件本身在终端中可以正常工作并且具有执行访问权限。

我编写了这段代码来配置 nginx,但它不起作用。

rtmp {
    server {
        listen 1935;
        chunk_size 4096;
        allow publish 127.0.0.1;
        deny publish all;

        application live {
            live on;
            record off;
        exec /my/path/to/transcode.sh $name;
    }
     }
 }
bash nginx sh rtmp
1个回答
0
投票

nginx 配置中的 exec 指令应包含在“push”块内。

rtmp {
    server {
        listen 1935;
        chunk_size 4096;
        allow publish 127.0.0.1;
        deny publish all;

        application live {
            live on;
            record off;
            push rtmp://your_destination_url;  # Add your destination URL here
            exec /my/path/to/transcode.sh $name;
        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.