1 Star 0 Fork 0

Markgor/nginx-rtmp-module

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
dash
doc
README.md
control_modul.md
debug_log.md
directives.md
examples.md
exec_wrapper_in_bash.md
faq.md
getting_number_of_subscribers.md
getting_started.md
installing_in_gentoo.md
installing_ubuntu_using_ppas.md
tutorial.md
hls
test
.gitignore
AUTHORS
LICENSE
README.md
config
ngx_rtmp.c
ngx_rtmp.h
ngx_rtmp_access_module.c
ngx_rtmp_amf.c
ngx_rtmp_amf.h
ngx_rtmp_auto_push_module.c
ngx_rtmp_bandwidth.c
ngx_rtmp_bandwidth.h
ngx_rtmp_bitop.c
ngx_rtmp_bitop.h
ngx_rtmp_cmd_module.c
ngx_rtmp_cmd_module.h
ngx_rtmp_codec_module.c
ngx_rtmp_codec_module.h
ngx_rtmp_control_module.c
ngx_rtmp_core_module.c
ngx_rtmp_eval.c
ngx_rtmp_eval.h
ngx_rtmp_exec_module.c
ngx_rtmp_flv_module.c
ngx_rtmp_handler.c
ngx_rtmp_handshake.c
ngx_rtmp_init.c
ngx_rtmp_limit_module.c
ngx_rtmp_live_module.c
ngx_rtmp_live_module.h
ngx_rtmp_log_module.c
ngx_rtmp_mp4_module.c
ngx_rtmp_netcall_module.c
ngx_rtmp_netcall_module.h
ngx_rtmp_notify_module.c
ngx_rtmp_play_module.c
ngx_rtmp_play_module.h
ngx_rtmp_proxy_protocol.c
ngx_rtmp_proxy_protocol.h
ngx_rtmp_receive.c
ngx_rtmp_record_module.c
ngx_rtmp_record_module.h
ngx_rtmp_relay_module.c
ngx_rtmp_relay_module.h
ngx_rtmp_send.c
ngx_rtmp_shared.c
ngx_rtmp_stat_module.c
ngx_rtmp_streams.h
ngx_rtmp_version.h
stat.xsl
克隆/下载
exec_wrapper_in_bash.md 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
Jan Stabenow 提交于 9年前 . MOD move wiki to /docs

Exec wrapper in bash

You can write exec wrapper in any language. However you should pay attention to termination process. When publisher closes the stream all executed processed get terminated. If you specify wrapper in exec directive instead of real ffmpeg then you might end up with your ffmpeg still alive and orphaned until it times out reading input data.

The solution is using signal traps. Here's an example of such wrapper in bash.

#!/bin/bash

on_die ()
{
    # kill all children
    pkill -KILL -P $$
}

trap 'on_die' TERM
ffmpeg -i rtmp://localhost/myapp/$1 -c copy -f flv rtmp://localhost/myapp2/$1 &
wait

The script registers SIGTERM handler which terminates child ffmpeg. Default signal sent by nginx-rtmp is SIGKILL which cannot be caught. For the above script to behave as expected you need to change exec kill signal with exec_kill_signal directive. It accept numeric or symbolic signal name (for POSIX.1-1990 signals). Here's example application.

application myapp {
    live on;

    exec /var/scripts/exec_wrapper.sh $name;
    exec_kill_signal term;
}

application myapp2 {
    live on;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/MarkGor/nginx-rtmp-module.git
git@gitee.com:MarkGor/nginx-rtmp-module.git
MarkGor
nginx-rtmp-module
nginx-rtmp-module
master

搜索帮助