sistason / rtmp_stream_delayer

Uses ffmpeg and nginx to delay (buffer) an incoming rtmp-stream for an amount of time.
GNU General Public License v2.0
42 stars 12 forks source link

Can we use this for creating delay while stream on twitch is already live? #13

Closed lmtdr closed 5 months ago

lmtdr commented 1 year ago

I start the stream in "realtime" and after i found a game i would like to prevent getting streamsniped. Am i able to put a delay into already running twitch stream? Some sort of RTMP switcher (switch from the main live rtmp to the delayed one) without canceling the stream on twitch itself? (to prevent more VODs creation and viewers being dropped out). Is that the main use of this script of Yours?

sistason commented 1 year ago

Prevention of streamsniping (or mandatory stream delays for casters, for the same reason) is the main use for this tool. Problem is, it keeps your stream delayed always the same time, even during disconnects, and makes sure the stream does not end during those (vods creation, viewer drop etc). Sadly, you can't really change the delay during streaming.

It would be possible to do that with the tools at hand here, but not by me. This tool was written in 2015 and I did not use it for 8 years. Apparently it works fine but, the support is a bit rusty...

The stream shows a "downtime-stream" during downtimes to keep the stream delayed, you could use that to show a video the viewers see while you build up delay for the actual stream delay. You'd need to do the control (possibly just a keyboard-press to the script) for the delay, the stream-delayer could start with X seconds delay and you could just edit that number on the fly, say increase to 5mins while showing video X, or decrease from 5 to 0 (and cut the last 5mins away for example, when you do a 5min break after a game for your viewers to catch up).

It sounds doable and nice, but I just don't stream anymore and so I won't be the person implementing this :(

invisan commented 5 months ago

Even though this "issue" is a bit older i wrote a similar script in bash with the help of the tool incron in Linux which does (almost) the same as your script. With some tweaks i found useful (changing the Delay on the fly based on the streamkey instead of the config, Announcements on Discord etc.)

@lmtdr the thing in your case is different from what the script is aimed for in both script cases though. As @sistason already said adding delay is possible. Both our scripts work similar in that they add the Delay to a recorded file. The thing is if you stream to twitch the Delayer has no idea when you disconnect from Twitch plus you somehow have to fill the void between the End of the "Live"Stream and the delayed Stream.

As example you stream live and find a Game you like and want to add 3 Minutes of Delay.

You can then if set up correctly stop your stream and connect to the delayer and it will add the Delay. But for both scripts it will first start a recording of that stream on your server before sending it out to Twitch. That will happen after the time for your specified Delay has run out. So you would have no connection to twitch for three Minutes. The only option with my script would be to start OBS or Streamlabs or your favorite other software a second time and stream it with the Delay Settings you want and close/stop the "live" stream once you almost are close to the time your delayed stream would be live.

So as example with the 3 Minutes provided above

At 15:00 you realize you would like to stream the Game with 3 Minutes Delay. You would then start OBS a second Time with the Option for 3 Minutes Delay. Wait till it reaches 2 Minutes and 50 Seconds and Stop your "Live" Stream. After that you can just let everything running.

Problem with that is that Webcams might not be working or other Stuff due to OBS being only able to grab the signal of a Device not in use.

You dont need a Delayer for stuff like that though. Since you can create the "Delay" with OBS like that and a direct connection to Twitch anyways.

sistason commented 5 months ago

nice work. Much appreciated you also build something like this, as I don't maintain my script anymore and thus it lacks features useful in 2024 (discord) which were not there when this was created in 2015 ;)

I will link to your repo in the readme to tell users to decide and maybe check out both to see which works better for them