From 17b7ac323d2594d43034971222dc5540e7aa9f6c Mon Sep 17 00:00:00 2001 From: Tibeuleu <> Date: Sat, 22 Nov 2025 22:31:21 +0100 Subject: [PATCH] mpv scripts --- .config/mpv/mpv.conf | 15 +- .config/mpv/scripts-opts/skipsilence.conf | 164 +++ .../scripts-opts/sponsorblock_minimal.conf | 16 + .config/mpv/scripts/skipsilence.lua | 1209 +++++++++++++++++ .config/mpv/scripts/sponsorblock_minimal.lua | 190 +-- 5 files changed, 1493 insertions(+), 101 deletions(-) create mode 100644 .config/mpv/scripts-opts/skipsilence.conf create mode 100644 .config/mpv/scripts-opts/sponsorblock_minimal.conf create mode 100644 .config/mpv/scripts/skipsilence.lua diff --git a/.config/mpv/mpv.conf b/.config/mpv/mpv.conf index da598f4..2c29f0a 100644 --- a/.config/mpv/mpv.conf +++ b/.config/mpv/mpv.conf @@ -73,7 +73,7 @@ # video outputs, but should work well with default settings on most systems. # If performance or energy usage is an issue, forcing the vdpau or vaapi VOs # may or may not help. -hwdec=auto +# hwdec=auto ################## # audio settings # @@ -97,7 +97,7 @@ hwdec=auto # other settings # ################## # -screenshot-template="%F_%p-%#01n" +# screenshot-template="%F_%p-%#01n" # automatically save the current playback position on quit save-position-on-quit @@ -109,11 +109,11 @@ save-position-on-quit # cache settings # # Use a large seekable RAM cache even for local input. -#cache=yes +cache=yes # # Use extra large RAM cache (needs cache=yes to make it useful). -#demuxer-max-bytes=500M -#demuxer-max-back-bytes=100M +demuxer-max-bytes=1G +demuxer-max-back-bytes=500M # # Disable the behavior that the player will pause if the cache goes below a # certain fill size. @@ -154,5 +154,6 @@ alang=fr,en # Streaming # ############# # Youtube Support -script-opts=ytdl_hook-ytdl_path=/home/t.barnouin/.local/bin/yt-dlp -ytdl-format=bestvideo[height<=?720][fps<=?30][vcodec!~='^(vp0?9|av0?1)']+bestaudio/best +script-opts=ytdl_hook-ytdl_path=/usr/bin/yt-dlp +ytdl-raw-options-append="extractor-args=youtube:player-client=default,-tv_simply" +ytdl-format=bestvideo[height>=?720][height<=?1080][fps<=?60][vcodec!~='^(vp0?9|av0?1)']+bestaudio/best diff --git a/.config/mpv/scripts-opts/skipsilence.conf b/.config/mpv/scripts-opts/skipsilence.conf new file mode 100644 index 0000000..845ea9d --- /dev/null +++ b/.config/mpv/scripts-opts/skipsilence.conf @@ -0,0 +1,164 @@ +# Whether skipsilence should be enabled by default. Can also be changed +# at runtime and reflects the current enabled state. +enabled = false, + +# The silence threshold in decibel. Anything quieter than this is +# detected as silence. Can be adjusted with the threshold-up, +# threshold-down bindings, and adjust-threshold-db script message. +threshold_db = -30, +# Minimum duration of silence to be detected, in seconds. This is +# measured in seconds of stream time, as if playback speed was 1. +threshold_duration = 0.1, +# How long to wait before speedup. This is measured in seconds of real +# time, thus higher playback speeds would reduce the length of content +# skipped. +# +# Ignored while `lookahead` is used. Use `margin_start` instead. +startdelay = 0.05, + +# How long to look ahead to allow slowing down ahead of end of silence. +# +# EXPERIMENTAL: Enabling this completely changes internal timing logic. It +# may be less reliable than operation without lookahead. +# +# Low values (~0.2s) tend to make filter adjustments (threshold_*) more +# jarring because of skipped audio. Higher values (~1.0s) cause a seek +# event instead, which may be less problematic. Do not set this too high, +# as it introduces additional buffering and could reduce timing precision. +# +# Recommended values are between 0.5 and 1.0. +# +# Option filter_persistent should be enabled for seamless toggling of the +# script. +lookahead = 0, + +# EXPERIMENTAL: For lookahead: Extra margin at start and end of detected +# silence. `margin_start` delays speed-up, `margin_end` slows down +# earlier, by the specified time. +# +# Measured in seconds of stream time. Negative values are allowed, having +# the opposite effect. +# +# Requires lookahead to be active. Maximum backwards adjustment is limited +# by the lookahead period (positive `margin_end` or negative +# `margin_start`). +margin_start = 0.05, +margin_end = 0, + +# EXPERIMENTAL: For lookahead: minimum length of silence for speed to be +# increased. This is a way to extend `threshold_duration` without needing +# to update the filter. +# +# Increases the required duration of silence, without delaying the +# starting point like startdelay (by up to the lookahead duration). +# Measured in seconds of stream time. +minduration = 0, + +# How often to update the speed during silence, in seconds of real time. +speed_updateinterval = 0.05, +# The maximum playback speed during silence. +speed_max = 4, + +# Speedup ramp parameters. The formula for playback speedup is: +# +# ramp_constant + (time * ramp_factor) ^ ramp_exponent +# +# Where time is the real time in seconds passed since start of speedup. +# The result is multiplied with the original playback speed. +# +# - ramp_constant should always be greater or equal to one, otherwise it +# will slow down at the start of silence. +# - Setting ramp_factor to 0 disables the ramp, resulting in a constant +# speed during silence. +# - ramp_exponent is the "acceleration" of the curve. A value of 1 +# results in a linear curve, values above 1 increase the speed faster +# the more time has passed, while values below 1 speed up at +# decreasing intervals. +ramp_constant = 1.25, +ramp_factor = 2.5, +ramp_exponent = 1, + +# EXPERIMENTAL: Same as ramp_* options, but for slowdown when using +# lookahead. 'time' is the remaining time to the end of silence. +# Note this is measured in stream time, different from the ramp_* +# options, which use real time. Choose a lower exponent to compensate. +# +# While slowdown ramp is active, always the lower speed calculated by the +# two ramps is used. +slowdown_ramp_constant = 1, +slowdown_ramp_factor = 3, +slowdown_ramp_exponent = 0.6, + +# Noise reduction filter configuration. +# +# This allows removing noise from the audio stream before the +# silencedetect filter, allowing to speed up pauses in speech despite +# background noise. The output audio is unaffected by default. +# +# Whether the detected audio signal should be preprocessed with arnndn. +# If arnndn_modelpath is empty, this has no effect +arnndn_enable = true, +# Path to the rnnn file containing the model parameters. If empty, +# noise reduction is disabled. +# The value is expanded with the expand-path command. See "Paths" in the +# mpv manual. +# Avoid special characters in this option, they must be escaped to +# work with "af add lavfi=[arnndn='...']". +arnndn_modelpath = "", +# Whether the denoised signal should be used as the output. Disabled by +# default, so the output is unaffected. +arnndn_output = false, + +# If >= 0, use this value instead of a playback speed of 1. +# This is a work around to stop audio clicks when switching between +# normal playback and speeding up. Playing back at a slightly different +# speed (e.g. 1.01x), keeps the scaletempo2 filter active, so audio is +# played back without interruptions. +alt_normal_speed = -1, + +# Workaround for audio-video de-synchronization with scaletempo2 in +# mpv 0.36 and below. When disabling skipsilence, fix audio sync if this +# many frames have been dropped since the last playback restart +# (seek, etc.). Disabled if value is less than 0. +# +# When disabling skipsilence while frame-drop-count is greater or equal +# to configured value, audio-video sync is fixed by running +# 'seek 0 exact'. May produce a short pause and/or audio repeat. +# +# Note that frame-drop-count does not exactly correspond to the +# audio-video desynchronization. It is used as a heuristic to avoid +# resyncing every time the script is disabled. Recommended value: 100. +resync_threshold_droppedframes = -1, + +# Keep the filter added while the script is disabled. This prevents +# most audio interruptions/clicks when toggling the script. +# If arnndn_output is enabled, noise reduction also stays active while +# the script is disabled. +filter_persistent = false, + +# Info style used for the 'user-data/skipsilence/info' property and +# the default of the 'info' script-message/binding. +# May be one of +# - 'off' (no information), +# - 'total' (show total saved time), +# - 'compact' (show total and latest saved time), +# - 'verbose' (show most information). +infostyle = "off", + +# When to reset the total saved time. +# May be one of +# - 'file-start' (when a new file starts) +# - 'never' (do not reset total) +reset_total = "file-start", + +# How to apply external speed change during silence. +# This makes speed change bindings work during fast forward. Set the +# value according to what command you use to change speed: +# - 'add' - add the difference to the normal speed +# - 'multiply' - multiply the normal speed with factor of change +# If 'off', the script will override the speed during silence. +# Note: this option is unreliable in cases where the script changes speed +# at the exact same time. Prefer the adjust-speed message instead. +apply_speed_change = "add", + +debug = false, diff --git a/.config/mpv/scripts-opts/sponsorblock_minimal.conf b/.config/mpv/scripts-opts/sponsorblock_minimal.conf new file mode 100644 index 0000000..0fd5acf --- /dev/null +++ b/.config/mpv/scripts-opts/sponsorblock_minimal.conf @@ -0,0 +1,16 @@ +# Default configuration options for mpv_sponsorblock_minimal + +# Category types that are skipped. Categories are separated by semicolons. +# List of categories can be found here: https://wiki.sponsor.ajay.app/w/Types +# To skip all categories except "filler", you could set this to: +# categories=sponsor +categories=sponsor;selfpromo;interaction;intro;outro;preview;hook + +# This option makes it so that the video ID will not be sent to the +# SponsorBlock server, but a part of the video ID's SHA256 hash will be sent +# instead. +# Set to "true" to enable this option. +hash=true + +# This sets the URL where the script gets the segments from. +server=https://sponsor.ajay.app/api/skipSegments diff --git a/.config/mpv/scripts/skipsilence.lua b/.config/mpv/scripts/skipsilence.lua new file mode 100644 index 0000000..95f5e2d --- /dev/null +++ b/.config/mpv/scripts/skipsilence.lua @@ -0,0 +1,1209 @@ +-- Increase playback speed during silence - a revolution in attention-deficit +-- induction technology. +-- +-- Main repository: https://codeberg.org/ferreum/mpv-skipsilence/ +-- +-- Features: +-- - Parameterized speedup ramp, allowing profiles for different kinds of +-- media (ramp_*, speed_*, startdelay options). +-- - Noise reduction of the detected signal. This allows to speed up +-- pauses in speech despite background noise. The output audio is +-- unaffected by default (arnndn_* options). +-- - Saved time estimation. +-- - Integration with osd-msg, auto profiles, etc. (with user-data, mpv 0.36 +-- and above only). +-- - Experimental: Lookahead for dynamic slowdown and faster reaction time +-- (`lookahead`, `slowdown_ramp_*`, `margin_*` options). +-- - Workaround for scaletempo2 audio-video desynchronization in mpv 0.36 and +-- below (resync_threshold_droppedframes option). +-- - Workaround for clicks during speed changes with scaletempo2 in mpv 0.36 +-- and below (alt_normal_speed option). +-- +-- Default bindings: +-- +-- F2 - toggle +-- F3 - threshold-down +-- F4 - threshold-up +-- +-- All supported bindings (bind with 'script-binding skipsilence/'): +-- +-- enable - enable the script, if it wasn't enabled. +-- disable - disable the script, if it was enabled. +-- toggle - toggle the script +-- threshold-down - decrease threshold_db by 1 (reduce amount skipped) +-- threshold-up - increase threshold_db by 1 (increase amount skipped) +-- info - show state info in osd +-- reset-total - reset total saved time statistic +-- cycle-info-style - cycle the infostyle option +-- toggle-arnndn - toggle the arnndn_enable option +-- toggle-arnndn-output - toggle the arnndn_output option +-- +-- Script messages (use with 'script-message-to skipsilence ...'): +-- +-- adjust-threshold-db +-- Adjust threshold_db by n. +-- enable [no-osd] +-- Enable the script. Passing 'no-osd' suppresses the osd message. +-- disable [] [no-osd] +-- Disable the script. If speed is specified, set the playback speed to +-- the given value instead of the normal playback speed. Passing 'no-osd' +-- suppresses the osd message. +-- toggle [no-osd] +-- Toggle the script. Passing 'no-osd' suppresses the osd message. +-- info [