38 lines
1.6 KiB
Diff
38 lines
1.6 KiB
Diff
|
diff -ruN mpvacious/main.lua mpvacious-patched/main.lua
|
||
|
--- mpvacious/main.lua 2024-07-22 15:31:00.090132616 -0400
|
||
|
+++ mpvacious-patched/main.lua 2024-07-24 17:51:37.378938337 -0400
|
||
|
@@ -1 +1,3 @@
|
||
|
+require("utils.force-japanese")
|
||
|
require('subs2srs')
|
||
|
diff -ruN mpvacious/utils/pause_cache.lua mpvacious-patched/utils/pause_cache.lua
|
||
|
--- mpvacious/utils/pause_cache.lua 1969-12-31 20:00:00.000000000 -0400
|
||
|
+++ mpvacious-patched/utils/pause_cache.lua 2024-07-24 17:51:16.124344874 -0400
|
||
|
@@ -0,0 +1,27 @@
|
||
|
+function on_load()
|
||
|
+ -- Get the system's total memory in MB
|
||
|
+ local mem_total = tonumber(io.popen("free -m | awk '/Mem:/ {print $2}'"):read())
|
||
|
+
|
||
|
+ -- Calculate the cache size based on total memory
|
||
|
+ local cache_size = math.floor(mem_total / 32) -- 128MB for 4GB RAM, increase proportionally
|
||
|
+
|
||
|
+ -- Set the cache size and enable caching
|
||
|
+ mp.set_property_number("cache", cache_size)
|
||
|
+ mp.set_property("demuxer-max-bytes", tostring(cache_size * 1024 * 1024)) -- Set cache size in bytes
|
||
|
+ mp.set_property("demuxer-readahead-secs", "20") -- Set read-ahead in seconds, adjust as needed
|
||
|
+end
|
||
|
+
|
||
|
+function on_pause_change(name, value)
|
||
|
+ if value == true then
|
||
|
+ -- When paused, reduce backward cache
|
||
|
+ mp.set_property("demuxer-back-bytes", "0")
|
||
|
+ else
|
||
|
+ -- When unpaused, reset backward cache
|
||
|
+ local mem_total = tonumber(io.popen("free -m | awk '/Mem:/ {print $2}'"):read())
|
||
|
+ local cache_size = math.floor(mem_total / 32)
|
||
|
+ mp.set_property("demuxer-back-bytes", tostring(cache_size * 1024 * 1024))
|
||
|
+ end
|
||
|
+end
|
||
|
+
|
||
|
+mp.register_event("file-loaded", on_load)
|
||
|
+mp.observe_property("pause", "bool", on_pause_change)
|