lossless1024 / StreaMonitor

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

post process script #65

Open amajio opened 1 year ago

amajio commented 1 year ago

I want to run post-process script after stream end using subprocess, so I can make contact sheet or convert file etc. But I don't know where to put it in a maze of code XD.

DerBunteBall commented 1 year ago

Just a few quick thoughts. No warranty that they are the best solution.

You would need to implement this in the downloaders package.

In StreaMonitor nearly everything is a thread. So a ffmpeg job de facto is a Thread which spawns a subprocess. Check downlaoders/ffmpeg.py for this. You could simply attach your post process script here after ffmpeg is finished. The downloader is sequentially run through. But you need the make sure that you can handle a stop. If you never execute one this wouldn't be important.

Another way would be to implement post processors in general. Create a package, define a base class (eventually also an interface) and implment child classes. This could be called from the downloader afterwards. A post processor could also be a Thread. You also could think about implmenting this as an async single thread. Keep in mind that your script or tool also is just a subprocess. A thread normally is the best solution for somputation. Async code is the best for IO. IO menas wating- calculating doing someting. So a thread which is async organized could keep track of all post process jobs and handle them.

Keep in mind that - in my opinion - there is no sensful Thread managment in StreaMonitor. So you could heavy overload a system by doing it wrong. You can't control how your downlaod threads will behave. So it could be sensful to implement something like a queue. Imagine 5 downlaods are stopping within 5 minutes after 4 hours of show. Depending on what you do in your post processing this can be much work for a normal desktop PC.

Hope this helps a bit.