nginx-ts-module icon indicating copy to clipboard operation
nginx-ts-module copied to clipboard

Add pull feature

Open miltador opened this issue 7 years ago • 6 comments

Add a pull feature in anology with nginx-rtmp-module.

miltador avatar Sep 19 '17 18:09 miltador

Pull as a separate feature is not planned. However I'm planning to implement a number of flexible execs instead.

arut avatar Sep 27 '17 15:09 arut

I've made the first approach to the exec pull feature. It works, but there's one question which I don't know how to address. Once a client requests an m3u8 or mpd file, nginx starts ffmpeg which publishes this stream. However at least the first request ends up with 404 anyway. If I keep restarting the page, it finally starts working. Still not sure if this should be addressed at client side by handling 404 properly or at server side by sending a fake manifest.

arut avatar Oct 01 '17 19:10 arut

I would think the "correct" way to handle it is to return code 503 with the "retry-after" header indicating a delay time. But that would depend on the browser & player honouring the delay indicated in the "retry-after" header and re-submitting the request.

ReubenM avatar Oct 10 '17 22:10 ReubenM

The best approach may be to de-couple the exec request from the player. So have a separate location that is designated with a ts_exec directive and has different commands for different path endpoints. So for example:

location /foo/ {
    ts_exec;
    exec_cmd ffmpeg -i bar <other arguments> path=bar;
    exec_cmd ffmpeg -i hash <other arguments> path=hash;
    exec_cmd ffmpeg -i $path <other arguments> path=$path;
}

So a GET request to /foo/bar would start the first command. A DELETE request to /foo/bar would result in SIGTERM being sent to that process. Likewise for the second command if the path used is /foo/hash. The third command would be a catch all allowing use of the path as a variable. So GET to /foo/bang would start the third command with the path variable expanding to "bang" when executed.

Then it's up to the developer using it to make sure a call is made to start the exec (and use HEAD to test for when the manifest is available) before ever trying to load the stream into the player.

ReubenM avatar Oct 10 '17 22:10 ReubenM

@arut Can you show a example of exec_pull feature?

0xVasconcelos avatar Dec 11 '17 04:12 0xVasconcelos

Can use exec_static like on rtmp module?

habibovic avatar Jan 25 '18 06:01 habibovic