lossless1024 / StreaMonitor

Adult live stream downloader for advanced people. I could have chosen a better name.
GNU General Public License v3.0
198 stars 52 forks source link

FFMpeg hanging the script never recovers #71

Open jimmyasmwest opened 1 year ago

jimmyasmwest commented 1 year ago

If ffmpeg hangs while recording the stream to mp4 it never recovers and will not record until the stream is stopped and started again.

Apologies this is the same as issue 42

jimmyasmwest commented 1 year ago

Changing the output to ts when passing it to ffmpeg on line 268 of bot.py appears to be essential to stop the recordings corrupting as i've lost quite alot recordings (may not be so common but i've had alot of connection problems of late)

DerBunteBall commented 1 year ago

This is known.

StreaMonitor has actually no code to monitor FFmpeg processes and will not always be able to "restart recording" because the model state can hang.

To have a better come out with file corruption you can change FFmpeg to caputre with MPEG-TS (MPEG Transport Stream; That's in fact like TV signal from satelite). Do this ind the ffmpeg downloader. This leads to working files but you would need to convert them to normal MP4 container files after that to have e.g. support on players which don't support this.

See #43 for that also. FFmpeg can be stopped now but the StreaMonitor has no idea about FFmpeg's state. So when it stucks it's not recognized. And so there is no garbadge collection for FFmpeg processes and no way to see the state or progress.

Because of that the model state can hang. So if FFmpeg hangs the state of the model thread (status check and ffmpeg are two threads) hangs in that state. So it's possible that the state isn't checked further.

jimmyasmwest commented 1 year ago

It's a very nice script, thank you! I have changed it to output to TS instead of mp4 to allow for playback (via VLC) while it's recording and for the file to be recovered if ffmpeg hangs or crashes. A minor issue I noticed is when removing a model using the controller it's case sensitive and setting DOWNLOADS_DIR in parameters.py is not reflected on the status page (status page is great, nice idea)

ThEnGI commented 1 year ago

Do this ind the ffmpeg downloader. This leads to working files but you would need to convert them to normal MP4 container files after that to have e.g. support on players which don't support this.

It can be parameterized and left to the user to decide I also tried changing line 251 of bot.py from .mp4 to .ts Let's see if there is any improvement

Even if lately with the improvement of the internet connection 99% of the problems have disappeared, it is still convenient to see the video during record