Sagnac / streamsave

mpv script aimed at saving live streams and clipping online videos without encoding.
94 stars 4 forks source link

Please assist with adjusting the Cache configuration to optimize the performance of autostart streamsave #19

Closed BoscoFZ closed 2 months ago

BoscoFZ commented 2 months ago

Below is my current Cache configuration. Could you please review it and help me adjust the Cache settings to achieve the best results with autostart savestream? I usually save streams in formats ranging from 720p to 4K. When opening the stream for saving, I always set it to autostart savestream, so I rarely interact with the mpv stream window. My computer has 32GB of RAM, and the number of streams being saved can vary—sometimes many, sometimes few. I want to ensure that the stream is saved completely with the best possible quality, without encountering unwanted issues such as image lag, even with a stable stream source. Thank you very much.

cache=yes demuxer-thread=yes demuxer-max-bytes=2048MiB demuxer-max-back-bytes=1024MiB demuxer-readahead-secs=3600

Sagnac commented 2 months ago

As stated in the README under Automation the cache settings don't really matter here since packets are being written to disk immediately; if anything you probably want to reduce the cache size if you're saving a lot of streams simultaneously in parallel so as not to consume too much memory.

Also, since you know you're going to be downloading from the start, if you're not watching the streams as you save them and you're not making use of the hostchange feature etc. you might want to consider just using yt-dlp directly to download the streams rather than mpv + this script.

BoscoFZ commented 2 months ago

As stated in the README under Automation the cache settings don't really matter here since packets are being written to disk immediately; if anything you probably want to reduce the cache size if you're saving a lot of streams simultaneously in parallel so as not to consume too much memory.

Also, since you know you're going to be downloading from the start, if you're not watching the streams as you save them and you're not making use of the hostchange feature etc. you might want to consider just using yt-dlp directly to download the streams rather than mpv + this script.

Thank you very much for your advice. I will reduce the cache value as suggested. Regarding the issue you mentioned about using yt-dlp directly for downloading, I had tried that before, but the problem is that I couldn't understand why yt-dlp fails to reconnect to the stream link when the connection drops and reconnects. That's why I'm currently using mpv in combination with savestream. If possible, could you suggest a command for yt-dlp that would enable it to reconnect automatically? Thank you very much.

Sagnac commented 2 months ago

yt-dlp fails to reconnect to the stream link when the connection drops and reconnects

If possible, could you suggest a command for yt-dlp that would enable it to reconnect automatically?

I personally haven't experienced that before so I can't offer much in the way of advice there. I guess in that case mpv + this script is a viable use case; part of the reason why I wrote the automation features was to support stuff like that, primarily the hostchange mechanism.

If you experience any issues reducing the cache size let me know; your settings seem reasonable as long as you're not saving a ton of streams at the same time, but the way you described your use case I think reducing the cache is probably better. Did you experience any issues before with those settings?

BoscoFZ commented 2 months ago

You are correct about the issue I'm currently facing: if I open too many streams to save, especially with 2K or 4K streams, it consumes a lot of resources. So, I think your advice is reasonable. If any issues arise, I will let you know. Thank you very much.