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

Cant run your script #7

Closed Trauni closed 3 years ago

Trauni commented 4 years ago

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

sistason commented 4 years ago

Heyo,

no probs :) The error shows that you run it with python2, not python3. Try to specifically start it with python3, e.g. sudo python3 rtmp_stream_delayer.py

Trauni commented 4 years ago

Oh my gosh thanks. One more question, sometimes if I start the script, it says "True" but nothing happens. What is the correct order to initiate the delayer? (I did starting the script in screen, detached, then I started the stream to the stream directory, but I also tried to start the script afterwards). Best

sistason commented 4 years ago

the script waits for a file to appear in the directory you configure. So "nothing" should happen until there are files, or directly, if you start it after recordings are already there. Try running it with -v, there should be debug output when a file was found (all files with .flv are valid. Maybe you don't save as flv? [flv is able to be interrupted and does not corrupt when closed unintentionally])

The "True" was debug, I removed it again^^

Trauni commented 4 years ago

Ah I understand its waiting for the delay time I set and then I will see the encoding process. The script wont do any ffmpeg settings right? So shit in is shit out? Its a 1 to 1 copy of the incoming stream.

sistason commented 4 years ago

exactly, copy codec ;)

https://github.com/sistason/rtmp_stream_delayer/blob/master/rtmp_stream_delayer.py#L103

It's usually what you want, as this is the delayer. Do you want to be sure that there is no transcoding, or do you want to suggest that to be configurable? If there is a use case for that, I'd implement it :)

Trauni commented 4 years ago

I did a test run yesterday and recorded the delayed session. The quality check will be today, so I will see if there is no quality loss.

One more question, will this work for the settings: STREAM_DESTINATION = 'rtmp://148.251.247.165/delay/map'

I want to use the nginx application "delay" with the key "map" so I dont have to set up applications per delayer.

Trauni commented 4 years ago

And one last question, how can I deny the deletion of source files after the delayer script is done.

sistason commented 4 years ago

you can stream to a DESTINATION with any URL your nginx can handle, so yes should work

The deletion of source files is handled in L#57. You can remove that command and replace it with "pass" or something

Trauni commented 3 years ago

Sorrs forgot to click close :)