exec任务进程

exec

Syntax: exec command arg*
Context: rtmp, server, application

exec is an alias of exec_push

exec_options

Syntax: exec_options on|off
Context: rtmp, server, application (see #1316)

The directive toggles exec options mode. When activated you can add exec-family directive options. The only exec option supported is name. This option makes it possible to apply exec only to specified stream. Default if off.

exec_options on;
# call my_on_publish_command only for "mystream"
exec_publish my_on_publish_command name=mystream;

# call my_on_play_command only for "another"
exec_play my_on_play_command name=another;

# execute different ffmpeg's for different streams
exec_pull ffmpeg -i https://example.com/abc.ts -c copy -f flv rtmp:https://localhost/$name/$app name=mystream;
exec_pull ffmpeg -i https://my.example.com/tele.ts -c copy -f flv rtmp:https://localhost/$name/$app name=tv;
exec_pull ffmpeg -i https://another.example.com/hello/f.ts -c copy -f flv rtmp:https://localhost/$name/$app name=fun;

exec_static

Syntax: exec_static command arg*
Context: rtmp, server, application

Similar to exec but runs specified command at nginx start. Does not support substitutions since has no session context.

exec_static ffmpeg -i https://example.com/video.ts -c copy -f flv rtmp:https://localhost/myapp/mystream;

exec_kill_signal

Syntax: exec_kill_signal signal
Context: rtmp, server, application

Sets process termination signal. Default is kill (SIGKILL). You can specify numeric or symbolic name (for POSIX.1-1990 signals).

exec_kill_signal term;
exec_kill_signal usr1;
exec_kill_signal 3;

respawn

Syntax: respawn on|off
Context: rtmp, server, application

If turned on respawns child process when it’s terminated while publishing is still on. Default is on;

respawn off;

respawn_timeout

Syntax: respawn_timeout timeout
Context: rtmp, server, application

Sets respawn timeout to wait before starting new child instance. Default is 5 seconds.

respawn_timeout 10s;

exec_publish

Syntax: exec_publish command arg*
Context: rtmp, server, application

Specifies external command with arguments to be executed on publish event. Return code is not analyzed. Substitutions of exec are supported here as well. In addition args variable is supported holding query string arguments.

exec_play

Syntax: exec_play command arg*
Context: rtmp, server, application

Specifies external command with arguments to be executed on play event. Return code is not analyzed. Substitution list is the same as for exec_publish.

exec_play_done

Syntax: exec_play_done command arg*
Context: rtmp, server, application

Specifies external command with arguments to be executed on play_done event. Return code is not analyzed. Substitution list is the same as for exec_publish.

exec_publish_done

Syntax: exec_publish_done command arg*
Context: rtmp, server, application

Specifies external command with arguments to be executed on publish_done event. Return code is not analyzed. Substitution list is the same as for exec_publish.

exec_record_done

Syntax: exec_record_done command arg*
Context: rtmp, server, application, recorder

Specifies external command with arguments to be executed when recording is finished. Substitution of exec_publish are supported here as well as additional variables

  • recorder - recorder name
  • path - recorded file path (/tmp/rec/mystream-1389499351.flv)
  • filename - path with directory omitted (mystream-1389499351.flv)
  • basename - file name with extension omitted (mystream-1389499351)
  • dirname - directory path (/tmp/rec)

Examples

# track client info
exec_play bash -c "echo $addr $pageurl >> /tmp/clients";
exec_publish bash -c "echo $addr $flashver >> /tmp/publishers";

# convert recorded file to mp4 format
exec_record_done ffmpeg -y -i $path -acodec libmp3lame -ar 44100 -ac 1 -vcodec libx264 $dirname/$basename.mp4;