Edward-Wu / srt-live-server

srt live server for low latency
Other
644 stars 192 forks source link

To pull from "ffmpeg" (exec a process) only when a connection is done. #6

Open Llorx opened 4 years ago

Llorx commented 4 years ago

I just want to transcode from x264 to x265 and send it through srt. The problem is that x265 es really hard performant so I can't have a couple of videos sending to srt when there's noone connected and pulling the video.

In nginx rtmp module there are options to run a process when a connection is received, passing the stream ID as an argument. Is there a chance to add this option here? So I can run ffmpeg only when a new connection is done (and kill it when the connection is finished), to save CPU cycles.

Edward-Wu commented 4 years ago

hi, Llorx You want to transcode x264 to x265 with ffmpeg, and send it throught srt. I think srt and ffmpeg are running in defferent process, and if srt is only handling net working event, which use cpu resource lightly. Can you tell me your question in detail?

ragnos commented 4 years ago

Bringing this up again because this would be a massive improvement in versatility.

nginx-rtmp offers multiple variants of running a external application during different states of operation, and offers multiple variables for use in the program call (eg. streamkey). This is essential eg. for transcoding or recording input.

For reference see https://github.com/arut/nginx-rtmp-module/wiki/Directives#exec

This feature in SLS would allow a wide variety of options for users of SLS with very little effort for you as developer, since we could offload all kinds of tasks to external tools like ffmpeg,

A possible usecase for SLS: On recieving a SRT input stream, a ffmpeg process is started which accesses a SRT output from SLS, transcoding it to different resolutions and afterwards mux it into HLS/DASH or other playout formats. The process is terminated when losing the input stream connection.

pkviet commented 3 years ago

+1 This is an important feature request. The capability to have exec directives exactly as in nginx will vastly improve this server. This will enable people to transmux, reencode, reroute easily by piping to ffmpeg for instance. (Member of Obs dev team here. I wrote the srt ouput code in obs-studio.)

zout commented 1 year ago

You can also have a separate process handle this via the HTTP call backs SLS can do on connect.

Think issue number 53 is the same suggestion.