sistason / rtmp_stream_delayer Goto Github PK
View Code? Open in Web Editor NEWUses ffmpeg and nginx to delay (buffer) an incoming rtmp-stream for an amount of time.
License: GNU General Public License v2.0
Uses ffmpeg and nginx to delay (buffer) an incoming rtmp-stream for an amount of time.
License: GNU General Public License v2.0
Hi!
I love the idea of this tool and would love to use it on my setup but I have no need for a backup stream and all that. I'd simply like to be able to add a stream delay at the nginx/rtmp level. Is there any optimization I can do to the Python scripts to just utilize that feature. Any help would be huge! Thanks!
Use record_append, so the destination-stream does not come down.
If no write is detected on the local file any more, check if the end shows a crash (TODO) and if it does, append the backup-stream until the file gets locked again by nginx, eg. the stream is up again.
Hello sir,
I`m trying to use another rtmp application of nginx as backup if the first source has an OBS crash or outage.
STREAM_DESTINATION = 'rtmp://148.251.247.165/delay/cf' DELAY = 17 # Seconds SINGLE = False # Set to true to just delay a single stream and exit, no reconnecting/backup-streams BACKUPSTREAM_SHORT = 'rtmp://148.251.247.165/backup/backup' # Show while intermission BACKUPSTREAM_LONG = 'rtmp://148.251.247.165/backup/backup' # Show while longer downtime FFMPEG_EXECUTABLE = "ffmpeg" # Use avconv if you need
But it ends up in "Error header information"
Best
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?
Hey sorry man, I am not the big brain in linux and python.
I tried to add your script to my rtmp server but if I start the script I will get this error messages:
Tried to start with: sudo python rtmp_stream_delayer.py /home/trauni/record/cleanfeed/
Traceback (most recent call last):
File "rtmp_stream_delayer.py", line 186, in
if check_running(PID_FILE):
File "rtmp_stream_delayer.py", line 166, in check_running
except FileNotFoundError:
NameError: global name 'FileNotFoundError' is not defined
My config:
delayer_settings:
STREAM_DESTINATION = 'rtmp://148.251.247.165/cf_delay'
DELAY = 120 # Seconds
SINGLE = True # Set to true to just delay a single stream and exit, no reconnecting/backup-streams
BACKUPSTREAM_SHORT = '' # Show while intermission
BACKUPSTREAM_LONG = '' # Show while longer downtime
FFMPEG_EXECUTABLE = "ffmpeg" # Use avconv if you need
nginx.conf
rtmp {
server {
listen 1935;
chunk_size 4096;
allow play all;
max_message 5M;
#Cleanfeed Application
application cleanfeed {
live on;
record all;
record_path /home/trauni/record/cleanfeed;
record_unique on;
record_suffix .flv;
record_append on;
}
#Delayer Script Application
application cf_delay{
live on;
record off;
}
}
}
Stream is running, flv file is generated and growing.
I can also open the stream in VLC and see its running into the correct application.
Thanks for help
I was wondering why the script would never publish my main stream from the file but always the backup stream. I don't know Python but is it correct that the publish_stream function will never set "ret = True" anywhere?
Just for testing I changed line 43 to "ret = True" and and finally my main stream was published. However, now it won't fall back to the backup stream if I end the main stream. The script will just end and delete the .flv file.
I doubt this line should exist:
Hi. Been unable to get this to work. Cant understand what the issue seems to be. I merged the nginx.conf file and it runs without an error. Tried streaming to ip:port/delay and the stream goes successfully via OBS without an error. I can see a file being created inside /tmp/nginx. Tried switching ports, endpoints of the outgoing servers, etc but no stream comes after the delay scheduled. Nothing goes out to Twitch, YouTube for example. Any help is appreciated.
Hello Sir,
we again expierencing a lot of troubles. Following is happening and it sounds like an network error but we only have this issues when we use the delay script. Maybe you can help us:
We are streaming to our Nginx-Server (a big 64GB RAM, i9 9900k machine on Ubuntu).
Delay is working fine
We also stream with 2 additional observer to the server without stream on different applications (but the error occurs also without them).
After more then 1 hour suddenly the upstream from OBS is not able to stream anymore to the server, the bitrate goes down to 0
On the server I see in the folder with the pid-file that all x-seconds a new 0Byte Flv file appears.
The delayer run into problem (Input wrong): Invalid data found when processing input
The sender is not able to restart OBS because the NGINX-RTMP Key is blocked.
I have to stop the delayer, restart nginx and then all things will work on but it happens also again after a couple of time.
I really dont understand what is going on, also asked the Server provider to send me network statistics.
Hello another big topic which happend a few times.
.
Sometimes the ffmpeg encoder stops to work with 2 errors:
I am not that programmer and I really dont understand a word in python but I found those two things:
https://stackoverflow.com/questions/38156265/getting-av-interleaved-write-frame-broken-pipe-error
https://stackoverflow.com/questions/50300013/ffmpeg-streaming-stops-after-few-seconds
I dont know if this is already in your code and I also dont know if this will solve my problems.
The biggest issue is, that we cant restart the stream after those errors without restarting the whole nginx service.
Normally the python should work on again after restarting the stream automatically, but it dont do that.
Quick note: we have 2-4 scripts running at the same time in several "screens".
Really great job with this @sistason and really appreciate the support.
Been trying to get the BACKUPSTREAM_SHORT and/or BACKUPSTREAM_LONG to work. Nothing seems to run though. Appreciate any guidance.
I guess I fixed this past in the time but I don`t know how.
Traceback (most recent call last): File "rtmp_stream_delayer.py", line 198, in <module> from delayer_settings import BACKUPSTREAM_SHORT, BACKUPSTREAM_LONG, \ ImportError: cannot import name 'FFMPEG_EXTRA_OPTS' from 'delayer_settings' (/etc/delay/regie-1-900s/delayer_settings.py)
STREAM_DESTINATION = 'rtmp://127.0.0.1/becleanfeed1/live' DELAY = 900 # Seconds SINGLE = False # Set to true to just delay a single stream and exit, no reconnecting/backup-streams BACKUPSTREAM_SHORT = '' # Show while intermission BACKUPSTREAM_LONG = '' # Show while longer downtime FFMPEG_EXECUTABLE = "ffmpeg" # Use avconv if you need
new server old issues I gues.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.