From 74883bc5a493207e1ee043a065b6eddd7cf8160b Mon Sep 17 00:00:00 2001 From: Eisa01 Date: Sun, 13 Aug 2023 03:55:25 -0700 Subject: [PATCH 1/9] skiptosilence: disable video/subtitle while skipping Disabling the video and subtitle while skipping instead of applying a blackout filter, fixes #3. When there are too many packets in the demuxer packet, caused by exceeding the expected inside a packet then skipping will not stop and result in the action to never end. This is resulted from subtitles and video output from my testing. Also fixed the script-opts template in the same PR. --- skiptosilence.lua | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/skiptosilence.lua b/skiptosilence.lua index cb60a5d..b3f4654 100644 --- a/skiptosilence.lua +++ b/skiptosilence.lua @@ -1,7 +1,7 @@ --[[ - * skiptosilence.lua v.2022-02-27 + * skiptosilence.lua v.2023-08-13 * - * AUTHORS: detuur, microraptor + * AUTHORS: detuur, microraptor, Eisa01 * License: MIT * link: https://github.com/detuur/mpv-scripts * @@ -23,14 +23,14 @@ # Maximum amount of noise to trigger, in terms of dB. # The default is -30 (yes, negative). -60 is very sensitive, # -10 is more tolerant to noise. -quietness = -30 +quietness=-30 # Minimum duration of silence to trigger. -duration = 0.1 +duration=0.1 # The fast-forwarded audio can sound jarring. Set to 'yes' # to mute it while skipping. -mutewhileskipping = no +mutewhileskipping=no ************************** END OF TEMPLATE ************************** --]] @@ -47,6 +47,8 @@ local options = require 'mp.options' old_speed = 1 was_paused = false was_muted = false +saved_sid = nil +saved_vid = nil --[[ Dev note about the used filters: @@ -63,20 +65,22 @@ function doSkip() -- Get video dimensions local width = mp.get_property_native("width"); local height = mp.get_property_native("height") + mp.set_property_native("geometry", ("%dx%d"):format(width, height)) - -- Create audio and video filters + -- Create filters mp.command( "no-osd af add @skiptosilence:lavfi=[silencedetect=noise=" .. opts.quietness .. "dB:d=" .. opts.duration .. "]" ) - mp.command( - "no-osd vf add @skiptosilence-blackout:lavfi=" .. - "[nullsink,color=c=black:s=" .. width .. "x" .. height .. "]" - ) -- Triggers whenever the `silencedetect` filter emits output mp.observe_property("af-metadata/skiptosilence", "string", foundSilence) + saved_vid = mp.get_property("vid") + mp.set_property("vid", "no") + saved_sid = mp.get_property("sid") + mp.set_property("sid", "no") + was_muted = mp.get_property_native("mute") if opts.mutewhileskipping then mp.set_property_bool("mute", true) @@ -98,15 +102,16 @@ function foundSilence(name, value) if timecode == nil or timecode < time_pos + 1 then return -- Ignore anything less than a second ahead. end - + + mp.set_property("vid", saved_vid) + mp.set_property("sid", saved_sid) mp.set_property_bool("mute", was_muted) mp.set_property_bool("pause", was_paused) mp.set_property("speed", old_speed) mp.unobserve_property(foundSilence) - -- Remove used audio and video filters + -- Remove used filters mp.command("no-osd af remove @skiptosilence") - mp.command("no-osd vf remove @skiptosilence-blackout") -- Seeking to the exact moment even though we've already -- fast forwarded here allows the video decoder to skip From f76f31a1afe02e2226381609c6f7ce7cee898dba Mon Sep 17 00:00:00 2001 From: Eisa01 Date: Tue, 15 Aug 2023 11:14:32 -0700 Subject: [PATCH 2/9] skiptosilence.lua: multiple enhancements and fixes Multiple enhancements and additions including: **Enhancements:** * Handle pause and file ending while skipping is triggered. * Pausing will revert to the initial trigger point and pause (cancels on-going skipping). * Changing / ending file will stop skipping towards the new loaded file. **Fixes:** * Fixed spamming `doSkip` (f3), causing crash. * Fixed script getting stuck when initiating `doSkip` (f3) at the end of file. **Miscs** * Removed mute option since mpv by default mutes speed 4x and above. * Renamed `duration` to `silence_duration` since other duration options are planned. * Removed obsolete filter comments and moved dev note up. * Changed indentation to tab. --- skiptosilence.lua | 180 +++++++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 83 deletions(-) diff --git a/skiptosilence.lua b/skiptosilence.lua index b3f4654..60619fd 100644 --- a/skiptosilence.lua +++ b/skiptosilence.lua @@ -1,5 +1,5 @@ --[[ - * skiptosilence.lua v.2023-08-13 + * skiptosilence.lua v.2023-08-15 * * AUTHORS: detuur, microraptor, Eisa01 * License: MIT @@ -19,115 +19,129 @@ * script-opts/skiptosilence.conf in mpv's user folder. The * parameters will be automatically loaded on start. * + * Dev note about the used filters: + * - `silencedetect` is an audio filter that listens for silence and + * emits text output with details whenever silence is detected. + * Filter documentation: https://ffmpeg.org/ffmpeg-filters.html ****************** TEMPLATE FOR skiptosilence.conf ****************** # Maximum amount of noise to trigger, in terms of dB. # The default is -30 (yes, negative). -60 is very sensitive, # -10 is more tolerant to noise. quietness=-30 -# Minimum duration of silence to trigger. -duration=0.1 - -# The fast-forwarded audio can sound jarring. Set to 'yes' -# to mute it while skipping. -mutewhileskipping=no +# Minimum duration of the silence that will be detected to trigger skipping. +silence_duration=0.1 ************************** END OF TEMPLATE ************************** --]] local opts = { - quietness = -30, - duration = 0.1, - mutewhileskipping = false + quietness = -30, + silence_duration = 0.1, } +(require 'mp.options').read_options(opts) local mp = require 'mp' local msg = require 'mp.msg' -local options = require 'mp.options' old_speed = 1 was_paused = false -was_muted = false saved_sid = nil saved_vid = nil - ---[[ -Dev note about the used filters: -- `silencedetect` is an audio filter that listens for silence and - emits text output with details whenever silence is detected. -- `nullsink` interrupts the video stream requests to the decoder, - which stops it from bogging down the fast-forward. -- `color` generates a blank image, which renders very quickly and is - good for fast-forwarding. -- Filter documentation: https://ffmpeg.org/ffmpeg-filters.html ---]] +skip_flag = false +initial_skip_time = 0 function doSkip() - -- Get video dimensions - local width = mp.get_property_native("width"); - local height = mp.get_property_native("height") - mp.set_property_native("geometry", ("%dx%d"):format(width, height)) - - -- Create filters - mp.command( - "no-osd af add @skiptosilence:lavfi=[silencedetect=noise=" .. - opts.quietness .. "dB:d=" .. opts.duration .. "]" - ) - - -- Triggers whenever the `silencedetect` filter emits output - mp.observe_property("af-metadata/skiptosilence", "string", foundSilence) - - saved_vid = mp.get_property("vid") - mp.set_property("vid", "no") - saved_sid = mp.get_property("sid") - mp.set_property("sid", "no") - - was_muted = mp.get_property_native("mute") - if opts.mutewhileskipping then - mp.set_property_bool("mute", true) - end - - was_paused = mp.get_property_native("pause") - mp.set_property_bool("pause", false) - old_speed = mp.get_property_native("speed") - mp.set_property("speed", 100) + if skip_flag then return end + -- Get initial time + initial_skip_time = mp.get_property_native("time-pos") + if math.floor(initial_skip_time) == math.floor(mp.get_property_native('duration')) then return end + + -- Get video dimensions + local width = mp.get_property_native("width"); + local height = mp.get_property_native("height") + mp.set_property_native("geometry", ("%dx%d"):format(width, height)) + + -- Create filters + mp.command( + "no-osd af add @skiptosilence:lavfi=[silencedetect=noise=" .. + opts.quietness .. "dB:d=" .. opts.silence_duration .. "]" + ) + + -- Triggers whenever the `silencedetect` filter emits output + mp.observe_property("af-metadata/skiptosilence", "string", foundSilence) + + saved_vid = mp.get_property("vid") + mp.set_property("vid", "no") + saved_sid = mp.get_property("sid") + mp.set_property("sid", "no") + was_paused = mp.get_property_native("pause") + mp.set_property_bool("pause", false) + old_speed = mp.get_property_native("speed") + mp.set_property("speed", 100) + skip_flag = true end function foundSilence(name, value) - if value == "{}" or value == nil then - return -- For some reason these are sometimes emitted. Ignore. - end - - timecode = tonumber(string.match(value, "%d+%.?%d+")) - time_pos = mp.get_property_native("time-pos") - if timecode == nil or timecode < time_pos + 1 then - return -- Ignore anything less than a second ahead. - end - - mp.set_property("vid", saved_vid) - mp.set_property("sid", saved_sid) - mp.set_property_bool("mute", was_muted) - mp.set_property_bool("pause", was_paused) - mp.set_property("speed", old_speed) - mp.unobserve_property(foundSilence) - - -- Remove used filters - mp.command("no-osd af remove @skiptosilence") - - -- Seeking to the exact moment even though we've already - -- fast forwarded here allows the video decoder to skip - -- the missed video. This prevents massive A-V lag. - mp.set_property_number("time-pos", timecode) - - -- If we don't wait at least 50ms before messaging the user, we - -- end up displaying an old value for time-pos. - mp.add_timeout(0.05, skippedMessage) + if value == "{}" or value == nil then + return -- For some reason these are sometimes emitted. Ignore. + end + + timecode = tonumber(string.match(value, "%d+%.?%d+")) + time_pos = mp.get_property_native("time-pos") + if timecode == nil or timecode < time_pos + 1 then + return -- Ignore anything less than a second ahead. + end + + mp.set_property("vid", saved_vid) + mp.set_property("sid", saved_sid) + mp.set_property_bool("pause", was_paused) + mp.set_property("speed", old_speed) + mp.unobserve_property(foundSilence) + + -- Remove used filters + mp.command("no-osd af remove @skiptosilence") + + -- Seeking to the exact moment even though we've already + -- fast forwarded here allows the video decoder to skip + -- the missed video. This prevents massive A-V lag. + mp.set_property_number("time-pos", timecode) + + -- If we don't wait at least 50ms before messaging the user, we + -- end up displaying an old value for time-pos. + mp.add_timeout(0.05, skippedMessage) + skip_flag = false end +mp.observe_property('pause', 'bool', function(name, value) + if value and skip_flag then + mp.set_property("vid", saved_vid) + mp.set_property("sid", saved_sid) + mp.set_property("speed", old_speed) + mp.unobserve_property(foundSilence) + mp.command("no-osd af remove @skiptosilence") + mp.set_property_number("time-pos", initial_skip_time) + mp.set_property_bool("pause", true) + skip_flag = false + end +end) + + +mp.add_hook('on_unload', 9, function() + if skip_flag then + mp.set_property("vid", saved_vid) + mp.set_property("sid", saved_sid) + mp.set_property("speed", old_speed) + mp.unobserve_property(foundSilence) + mp.command("no-osd af remove @skiptosilence") + mp.set_property_number("time-pos", mp.get_property_number("time-pos")) + mp.set_property_bool("pause", was_paused) + skip_flag = false + end +end) + function skippedMessage() - msg.info("Skipped to silence at " .. mp.get_property_osd("time-pos")) - mp.osd_message("Skipped to silence at " .. mp.get_property_osd("time-pos")) + msg.info("Skipped to silence at " .. mp.get_property_osd("time-pos")) + mp.osd_message("Skipped to silence at " .. mp.get_property_osd("time-pos")) end -options.read_options(opts) - mp.add_key_binding("F3", "skip-to-silence", doSkip) From ed1f46fe5da799b3f291bfbf23267950fa85f991 Mon Sep 17 00:00:00 2001 From: Eisa01 Date: Thu, 17 Aug 2023 06:52:14 -0700 Subject: [PATCH 3/9] skiptosilence.lua: fix for ignoring anything less than a second ahead Fix for ignore anything less than a second ahead caused, it was caused due to disabling video while seeking. --- skiptosilence.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/skiptosilence.lua b/skiptosilence.lua index 60619fd..d3b5363 100644 --- a/skiptosilence.lua +++ b/skiptosilence.lua @@ -86,9 +86,7 @@ function foundSilence(name, value) return -- For some reason these are sometimes emitted. Ignore. end - timecode = tonumber(string.match(value, "%d+%.?%d+")) - time_pos = mp.get_property_native("time-pos") - if timecode == nil or timecode < time_pos + 1 then + if timecode == nil or timecode < initial_skip_time + 1 then return -- Ignore anything less than a second ahead. end From 7f2cfea9423a451278fd2b972c14a1c1d46c6826 Mon Sep 17 00:00:00 2001 From: Eisa01 Date: Fri, 18 Aug 2023 06:57:58 -0700 Subject: [PATCH 4/9] skiptosilence.lua: multiple new features and bug fixes Fixed crashes related to changes in previous PR. Renamed user config to make it easier for users. Added multiple new options: Reverted removal of force mute: (force_mute_on_skip) Added the following new options: ignore_silence_duration=10 min_skip_duration=0 max_skip_duration=120 force_mute_on_skip=no osd_msg=yes --- skiptosilence.lua | 172 ++++++++++++++++++++++++++++------------------ 1 file changed, 105 insertions(+), 67 deletions(-) diff --git a/skiptosilence.lua b/skiptosilence.lua index d3b5363..2b883a9 100644 --- a/skiptosilence.lua +++ b/skiptosilence.lua @@ -1,5 +1,5 @@ --[[ - * skiptosilence.lua v.2023-08-15 + * skiptosilence.lua v.2023-08-18 * * AUTHORS: detuur, microraptor, Eisa01 * License: MIT @@ -24,122 +24,160 @@ * emits text output with details whenever silence is detected. * Filter documentation: https://ffmpeg.org/ffmpeg-filters.html ****************** TEMPLATE FOR skiptosilence.conf ****************** -# Maximum amount of noise to trigger, in terms of dB. -# The default is -30 (yes, negative). -60 is very sensitive, -# -10 is more tolerant to noise. -quietness=-30 +#--(#number). Maximum amount of noise to trigger, in terms of dB. Lower is more sensitive. +silence_audio_level=-40 -# Minimum duration of the silence that will be detected to trigger skipping. -silence_duration=0.1 +#--(#number). Duration of the silence that will be detected to trigger skipping. +silence_duration=0.7 + +#--(0/#number). The first detcted silence_duration will be ignored for the defined seconds in this option, and it will continue skipping until the next silence_duration. +# (0 for disabled, or specify seconds). +ignore_silence_duration=10 + +#--(0/#number). Minimum amount of seconds accepted to skip until the configured silence_duration. +# (0 for disabled, or specify seconds) +min_skip_duration=0 + +#--(0/#number). Maximum amount of seconds accepted to skip until the configured silence_duration. +# (0 for disabled, or specify seconds) +max_skip_duration=120 + +#--(yes/no). Default is muted, however if audio was enabled due to custom mpv settings, the fast-forwarded audio can sound jarring. +force_mute_on_skip=no + +#--(yes/no). Display osd messages when actions occur. +osd_msg=yes ************************** END OF TEMPLATE ************************** --]] -local opts = { - quietness = -30, - silence_duration = 0.1, +local o = { + silence_audio_level = -40, + silence_duration = 0.7, + ignore_silence_duration=1, + min_skip_duration = 0, + max_skip_duration = 120, + force_mute_on_skip = false, + osd_msg = true, } -(require 'mp.options').read_options(opts) +(require 'mp.options').read_options(o) local mp = require 'mp' local msg = require 'mp.msg' -old_speed = 1 -was_paused = false -saved_sid = nil -saved_vid = nil +speed_state = 1 +pause_state = false +mute_state = false +sid_state = nil +vid_state = nil skip_flag = false initial_skip_time = 0 +function restoreProp(timepos,pause) + if not timepos then timepos = mp.get_property_number("time-pos") end + if not pause then pause = pause_state end + + mp.set_property("vid", vid_state) + mp.set_property("sid", sid_state) + mp.set_property_bool("mute", mute_state) + mp.set_property("speed", speed_state) + mp.unobserve_property(foundSilence) + mp.command("no-osd af remove @skiptosilence") + mp.set_property_number("time-pos", timepos) + mp.set_property_bool("pause", pause) + timer:kill() + skip_flag = false +end + +function handleMinMaxDuration(timepos) + if not skip_flag then return end + if not timepos then timepos = mp.get_property_number("time-pos") end + + skip_duration = timepos - initial_skip_time + if o.min_skip_duration > 0 and skip_duration <= o.min_skip_duration then + restoreProp(initial_skip_time) + if o.osd_msg then mp.osd_message('Skipping Cancelled\nSilence is less than configured minimum') end + msg.info('Skipping Cancelled\nSilence is less than configured minimum') + return true + end + if o.max_skip_duration > 0 and skip_duration >= o.max_skip_duration then + restoreProp(initial_skip_time) + if o.osd_msg then mp.osd_message('Skipping Cancelled\nSilence is more than configured maximum') end + msg.info('Skipping Cancelled\nSilence is more than configured maximum') + return true + end + return false +end + +function skippedMessage() + if o.osd_msg then mp.osd_message("Skipped to silence at " .. mp.get_property_osd("time-pos")) end + msg.info("Skipped to silence at " .. mp.get_property_osd("time-pos")) +end + function doSkip() if skip_flag then return end - -- Get initial time - initial_skip_time = mp.get_property_native("time-pos") - if math.floor(initial_skip_time) == math.floor(mp.get_property_native('duration')) then return end - - -- Get video dimensions + initial_skip_time = (mp.get_property_native("time-pos") or 0) + if math.floor(initial_skip_time) == math.floor(mp.get_property_native('duration') or 0) then return end + local width = mp.get_property_native("width"); local height = mp.get_property_native("height") mp.set_property_native("geometry", ("%dx%d"):format(width, height)) - -- Create filters mp.command( "no-osd af add @skiptosilence:lavfi=[silencedetect=noise=" .. - opts.quietness .. "dB:d=" .. opts.silence_duration .. "]" + o.silence_audio_level .. "dB:d=" .. o.silence_duration .. "]" ) - -- Triggers whenever the `silencedetect` filter emits output mp.observe_property("af-metadata/skiptosilence", "string", foundSilence) - saved_vid = mp.get_property("vid") + vid_state = mp.get_property("vid") mp.set_property("vid", "no") - saved_sid = mp.get_property("sid") + sid_state = mp.get_property("sid") mp.set_property("sid", "no") - was_paused = mp.get_property_native("pause") + mute_state = mp.get_property_native("mute") + if o.force_mute_on_skip then + mp.set_property_bool("mute", true) + end + pause_state = mp.get_property_native("pause") mp.set_property_bool("pause", false) - old_speed = mp.get_property_native("speed") + speed_state = mp.get_property_native("speed") mp.set_property("speed", 100) skip_flag = true + + timer = mp.add_periodic_timer(0.5, function() + local video_time = (mp.get_property_native("time-pos") or 0) + handleMinMaxDuration(video_time) + end) end function foundSilence(name, value) if value == "{}" or value == nil then - return -- For some reason these are sometimes emitted. Ignore. + return end - - if timecode == nil or timecode < initial_skip_time + 1 then - return -- Ignore anything less than a second ahead. + + timecode = tonumber(string.match(value, "%d+%.?%d+")) + if timecode == nil or timecode < initial_skip_time + o.ignore_silence_duration then --1.03# this is to ignore silence + return end - mp.set_property("vid", saved_vid) - mp.set_property("sid", saved_sid) - mp.set_property_bool("pause", was_paused) - mp.set_property("speed", old_speed) - mp.unobserve_property(foundSilence) - - -- Remove used filters - mp.command("no-osd af remove @skiptosilence") - - -- Seeking to the exact moment even though we've already - -- fast forwarded here allows the video decoder to skip - -- the missed video. This prevents massive A-V lag. - mp.set_property_number("time-pos", timecode) + if handleMinMaxDuration(timecode) then return end + + restoreProp(timecode) - -- If we don't wait at least 50ms before messaging the user, we - -- end up displaying an old value for time-pos. mp.add_timeout(0.05, skippedMessage) skip_flag = false end mp.observe_property('pause', 'bool', function(name, value) if value and skip_flag then - mp.set_property("vid", saved_vid) - mp.set_property("sid", saved_sid) - mp.set_property("speed", old_speed) - mp.unobserve_property(foundSilence) - mp.command("no-osd af remove @skiptosilence") - mp.set_property_number("time-pos", initial_skip_time) - mp.set_property_bool("pause", true) - skip_flag = false + restoreProp(initial_skip_time, true) end end) mp.add_hook('on_unload', 9, function() if skip_flag then - mp.set_property("vid", saved_vid) - mp.set_property("sid", saved_sid) - mp.set_property("speed", old_speed) - mp.unobserve_property(foundSilence) - mp.command("no-osd af remove @skiptosilence") - mp.set_property_number("time-pos", mp.get_property_number("time-pos")) - mp.set_property_bool("pause", was_paused) - skip_flag = false + restoreProp() end end) -function skippedMessage() - msg.info("Skipped to silence at " .. mp.get_property_osd("time-pos")) - mp.osd_message("Skipped to silence at " .. mp.get_property_osd("time-pos")) -end - mp.add_key_binding("F3", "skip-to-silence", doSkip) From 60202aea8259b31101c5e3d040bde507f2752bd0 Mon Sep 17 00:00:00 2001 From: Eisa01 Date: Fri, 18 Aug 2023 07:00:24 -0700 Subject: [PATCH 5/9] skiptosilence.lua: Template config updated Slight update for config template --- skiptosilence.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skiptosilence.lua b/skiptosilence.lua index 2b883a9..83bbf7f 100644 --- a/skiptosilence.lua +++ b/skiptosilence.lua @@ -32,7 +32,7 @@ silence_duration=0.7 #--(0/#number). The first detcted silence_duration will be ignored for the defined seconds in this option, and it will continue skipping until the next silence_duration. # (0 for disabled, or specify seconds). -ignore_silence_duration=10 +ignore_silence_duration=1 #--(0/#number). Minimum amount of seconds accepted to skip until the configured silence_duration. # (0 for disabled, or specify seconds) From 665e889b65bc67c75ef0edc54c5bab0975d27ef4 Mon Sep 17 00:00:00 2001 From: Eisa01 Date: Wed, 23 Aug 2023 11:28:11 -0700 Subject: [PATCH 6/9] skiptosilence.lua: fix wrong height, width, added force-window Fixed wrong height and width as osd should be used. Added force-window so that mpv doesn't minimize when launched via terminal. --- skiptosilence.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/skiptosilence.lua b/skiptosilence.lua index 83bbf7f..649de81 100644 --- a/skiptosilence.lua +++ b/skiptosilence.lua @@ -1,5 +1,5 @@ --[[ - * skiptosilence.lua v.2023-08-18 + * skiptosilence.lua v.2023-08-23 * * AUTHORS: detuur, microraptor, Eisa01 * License: MIT @@ -69,6 +69,7 @@ pause_state = false mute_state = false sid_state = nil vid_state = nil +window_state = nil skip_flag = false initial_skip_time = 0 @@ -77,6 +78,7 @@ function restoreProp(timepos,pause) if not pause then pause = pause_state end mp.set_property("vid", vid_state) + mp.set_property("force-window", window_state) mp.set_property("sid", sid_state) mp.set_property_bool("mute", mute_state) mp.set_property("speed", speed_state) @@ -118,8 +120,8 @@ function doSkip() initial_skip_time = (mp.get_property_native("time-pos") or 0) if math.floor(initial_skip_time) == math.floor(mp.get_property_native('duration') or 0) then return end - local width = mp.get_property_native("width"); - local height = mp.get_property_native("height") + local width = mp.get_property_native("osd-width") + local height = mp.get_property_native("osd-height") mp.set_property_native("geometry", ("%dx%d"):format(width, height)) mp.command( @@ -129,6 +131,8 @@ function doSkip() mp.observe_property("af-metadata/skiptosilence", "string", foundSilence) + window_state = mp.get_property("force-window") + mp.set_property("force-window", "yes") vid_state = mp.get_property("vid") mp.set_property("vid", "no") sid_state = mp.get_property("sid") From 9abf1cd1ce01e2e8d6d3e82e06b456a7a30672d5 Mon Sep 17 00:00:00 2001 From: Eisa01 Date: Wed, 23 Aug 2023 11:29:01 -0700 Subject: [PATCH 7/9] skiptosilence.lua: remove comments removed dev comments to make script smaller. --- skiptosilence.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skiptosilence.lua b/skiptosilence.lua index 649de81..2b874e5 100644 --- a/skiptosilence.lua +++ b/skiptosilence.lua @@ -159,7 +159,7 @@ function foundSilence(name, value) end timecode = tonumber(string.match(value, "%d+%.?%d+")) - if timecode == nil or timecode < initial_skip_time + o.ignore_silence_duration then --1.03# this is to ignore silence + if timecode == nil or timecode < initial_skip_time + o.ignore_silence_duration then return end From 165b5074aa5f00d72fa8bb14fb8feef5759159ad Mon Sep 17 00:00:00 2001 From: Eisa01 Date: Sat, 26 Aug 2023 14:51:16 -0700 Subject: [PATCH 8/9] skiptosilence.lua: fix getting stuck with autoload script autoload script caused script to get stuck due to loading of sid. removed changing sid state and replaced with sub-visibility. --- skiptosilence.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/skiptosilence.lua b/skiptosilence.lua index 2b874e5..7ecebfd 100644 --- a/skiptosilence.lua +++ b/skiptosilence.lua @@ -67,7 +67,8 @@ local msg = require 'mp.msg' speed_state = 1 pause_state = false mute_state = false -sid_state = nil +sub_state = nil +secondary_sub_state = nil vid_state = nil window_state = nil skip_flag = false @@ -79,13 +80,14 @@ function restoreProp(timepos,pause) mp.set_property("vid", vid_state) mp.set_property("force-window", window_state) - mp.set_property("sid", sid_state) mp.set_property_bool("mute", mute_state) mp.set_property("speed", speed_state) mp.unobserve_property(foundSilence) mp.command("no-osd af remove @skiptosilence") + mp.set_property_bool("pause", pause) mp.set_property_number("time-pos", timepos) - mp.set_property_bool("pause", pause) + mp.set_property("sub-visibility", sub_state) + mp.set_property("secondary-sub-visibility", secondary_sub_state) timer:kill() skip_flag = false end @@ -131,12 +133,14 @@ function doSkip() mp.observe_property("af-metadata/skiptosilence", "string", foundSilence) + sub_state = mp.get_property("sub-visibility") + mp.set_property("sub-visibility", "no") + secondary_sub_state = mp.get_property("secondary-sub-visibility") + mp.set_property("secondary-sub-visibility", "no") window_state = mp.get_property("force-window") mp.set_property("force-window", "yes") vid_state = mp.get_property("vid") mp.set_property("vid", "no") - sid_state = mp.get_property("sid") - mp.set_property("sid", "no") mute_state = mp.get_property_native("mute") if o.force_mute_on_skip then mp.set_property_bool("mute", true) From 68d8e36c699cbea4d6140bee6762ff8f49a47f89 Mon Sep 17 00:00:00 2001 From: Eisa01 Date: Sun, 27 Aug 2023 07:02:14 +0400 Subject: [PATCH 9/9] skiptosilence.lua: update date --- skiptosilence.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skiptosilence.lua b/skiptosilence.lua index 7ecebfd..ab25489 100644 --- a/skiptosilence.lua +++ b/skiptosilence.lua @@ -1,5 +1,5 @@ --[[ - * skiptosilence.lua v.2023-08-23 + * skiptosilence.lua v.2023-08-27 * * AUTHORS: detuur, microraptor, Eisa01 * License: MIT