mpv scripts

This commit is contained in:
Tibeuleu
2025-11-22 22:31:21 +01:00
parent 883c4cabb0
commit 17b7ac323d
5 changed files with 1493 additions and 101 deletions

View File

@@ -73,7 +73,7 @@
# video outputs, but should work well with default settings on most systems. # 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 # If performance or energy usage is an issue, forcing the vdpau or vaapi VOs
# may or may not help. # may or may not help.
hwdec=auto # hwdec=auto
################## ##################
# audio settings # # audio settings #
@@ -97,7 +97,7 @@ hwdec=auto
# other settings # # other settings #
################## ##################
# #
screenshot-template="%F_%p-%#01n" # screenshot-template="%F_%p-%#01n"
# automatically save the current playback position on quit # automatically save the current playback position on quit
save-position-on-quit save-position-on-quit
@@ -109,11 +109,11 @@ save-position-on-quit
# cache settings # cache settings
# #
# Use a large seekable RAM cache even for local input. # 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). # Use extra large RAM cache (needs cache=yes to make it useful).
#demuxer-max-bytes=500M demuxer-max-bytes=1G
#demuxer-max-back-bytes=100M demuxer-max-back-bytes=500M
# #
# Disable the behavior that the player will pause if the cache goes below a # Disable the behavior that the player will pause if the cache goes below a
# certain fill size. # certain fill size.
@@ -154,5 +154,6 @@ alang=fr,en
# Streaming # # Streaming #
############# #############
# Youtube Support # Youtube Support
script-opts=ytdl_hook-ytdl_path=/home/t.barnouin/.local/bin/yt-dlp script-opts=ytdl_hook-ytdl_path=/usr/bin/yt-dlp
ytdl-format=bestvideo[height<=?720][fps<=?30][vcodec!~='^(vp0?9|av0?1)']+bestaudio/best 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

View File

@@ -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,

View File

@@ -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

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,7 @@
-- This script skips sponsored segments of YouTube videos -- This script skips sponsored segments of YouTube videos
-- using data from https://github.com/ajayyy/SponsorBlock -- using data from https://github.com/ajayyy/SponsorBlock
local mp = require "mp"
local opt = require 'mp.options' local opt = require 'mp.options'
local utils = require 'mp.utils' local utils = require 'mp.utils'
@@ -55,7 +56,8 @@ function file_loaded()
local youtube_id = nil local youtube_id = nil
local purl = mp.get_property("metadata/by-key/PURL", "") local purl = mp.get_property("metadata/by-key/PURL", "")
for i, url in ipairs(urls) do for i, url in ipairs(urls) do
youtube_id = youtube_id or string.match(video_path, url) or string.match(video_referer, url) or string.match(purl, url) youtube_id = youtube_id or string.match(video_path, url) or string.match(video_referer, url) or
string.match(purl, url)
if youtube_id then break end if youtube_id then break end
end end