ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.

Home Page:https://ossrs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Migrate from NGINX-RTMP, support exec

winlinvip opened this issue · comments

This wiki discusses the handling of the exec signal SIGTERM.
https://github.com/arut/nginx-rtmp-module/wiki/Exec-wrapper-in-bash

TRANS_BY_GPT3

This mentions executing "exec_record_done" when the DVR ends, adding metadata to the FLV file.
https://github.com/arut/nginx-rtmp-module/wiki/FAQ#seek-does-not-work-with-flv-files-recorded-by-the-module

TRANS_BY_GPT3

exec is mainly introduced in this wiki: https://github.com/arut/nginx-rtmp-module/wiki/Directives#exec

'
Please make sure to maintain the markdown structure.

TRANS_BY_GPT3

https://github.com/arut/nginx-rtmp-module/wiki/Directives#exec_push

exec_push command arg*

Specifies external command with arguments to be executed on every stream published. When publishing stops the process is terminated.

NGINX-RTMP is a program that is executed during streaming and sends a quit signal to the program when the streaming ends.

The available variables include:

$name - stream name
$app - application name
$addr - client address
$flashver - client flash version
$swfurl - client swf url
$tcurl - client tc url
$pageurl - client page url

TRANS_BY_GPT3

https://github.com/arut/nginx-rtmp-module/wiki/Directives#exec_pull

exec_pull command arg*

Specifies external command with arguments to be executed on play event. The command is executed when first client connects to the stream and is killed when the last one disconnects. This directive makes it possible to pull remote stream in any format for local clients.

When the first client starts playing, the process is initiated. The program ends when the last client exits.

TRANS_BY_GPT3

https://github.com/arut/nginx-rtmp-module/wiki/Directives#exec_static
Ingest can be considered as an implementation of this feature.

TRANS_BY_GPT3

https://github.com/arut/nginx-rtmp-module/wiki/Directives#respawn
NGINX-RTMP will restart the process when the process exits while the stream is still active.

TRANS_BY_GPT3

https://github.com/arut/nginx-rtmp-module/wiki/Directives#exec_record_done
Command executed upon completion of the DVR.

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)

TRANS_BY_GPT3

It seems that these exec commands only need to support two options:

  1. exec: Start a process when the streaming starts.
  2. exec_on_dvr: Also known as exec_record_done, start a program when the recording is completed.

TRANS_BY_GPT3

https://github.com/arut/nginx-rtmp-module/wiki/Directives#on_record_done
NGINX-RTMP also provides HTTP callbacks, similar to SRS's on_dvr.

TRANS_BY_GPT3

I haven't decided whether to support exec yet, so let's put this feature on hold.

TRANS_BY_GPT3

This feature indeed compromises the integrity of SRS. There is no need to support a broad feature when HTTP callback can completely replace it and is more flexible. Let's postpone this to SRS4.

TRANS_BY_GPT3

Still, let's stick with SRS3.

TRANS_BY_GPT3

# the vhost for exec, fork process when publish stream.
vhost exec.srs.com {
    # the exec used to fork process when got some event.
    exec {
        # whether enable the exec.
        # default: off.
        enabled     off;
        # when publish stream, exec the process with variables:
        #       [vhost] the input stream vhost.
        #       [port] the intput stream port.
        #       [app] the input stream app.
        #       [stream] the input stream name.
        #       [engine] the tanscode engine name.
        # other variables for exec only:
        #       [url] the rtmp url which trigger the publish.
        #       [tcUrl] the client request tcUrl.
        #       [swfUrl] the client request swfUrl.
        #       [pageUrl] the client request pageUrl.
        # @remark empty to ignore this exec.
        publish     ./objs/ffmpeg/bin/ffmpeg -f flv -i [url] -c copy -y ./[stream].flv;
    }
}

Has the 'exec' function been added?

TRANS_BY_GPT3