Skip to content

Commit

Permalink
新缩略图引擎:支持关闭短视频的预览与解码频率调节
Browse files Browse the repository at this point in the history
  • Loading branch information
hooke007 committed Oct 10, 2022
1 parent a72f21d commit 925934c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
22 changes: 12 additions & 10 deletions portable_config/script-opts.conf
Original file line number Diff line number Diff line change
Expand Up @@ -413,20 +413,22 @@
##⇘⇘新缩略图引擎

script-opts-append = thumbfast-socket=
# Socket 路径,留空即自动
# Socket 路径,留空即自动
script-opts-append = thumbfast-tnpath=
# 缩略图缓存路径,留空即自动
script-opts-append = thumbfast-max_height=300 # 缩略图的尺寸,以像素为单位,默认 300 300
# 缩略图缓存路径,留空即自动
script-opts-append = thumbfast-max_height=300 # 缩略图的尺寸,以像素为单位,默认 300 300
script-opts-append = thumbfast-max_width=300
script-opts-append = thumbfast-max_thumbs=1440 # 缩略图的最高数量,默认 1440
script-opts-append = thumbfast-max_thumbs=1440 # 缩略图的最高数量,默认 1440

script-opts-append = thumbfast-overlay_id=42 # 勿改
script-opts-append = thumbfast-overlay_id=42 # 勿改

script-opts-append = thumbfast-spawn_first=no # 加载文件时就开始生成缩略图,默认 no
script-opts-append = thumbfast-network=no # 是否对流媒体启用,默认 no
script-opts-append = thumbfast-audio=no # 是否对音频文件启用,默认 no
script-opts-append = thumbfast-precise=yes # 是否使用高精度的预览,默认 yes
script-opts-append = thumbfast-hwdec=yes # 是否使用硬解加速,默认 yes
script-opts-append = thumbfast-spawn_first=no # 加载文件时就开始生成缩略图,默认 no
script-opts-append = thumbfast-network=no # 是否对流媒体启用,默认 no
script-opts-append = thumbfast-audio=no # 是否对音频文件启用,默认 no
script-opts-append = thumbfast-min_duration=0 # 是否只对时长高于该值的视频启用(秒),默认 0 即禁用
script-opts-append = thumbfast-precise=yes # 是否使用高精度的预览,默认 yes
script-opts-append = thumbfast-hwdec=yes # 是否使用硬解加速,默认 yes
script-opts-append = thumbfast-frequency=0.2 # 解码频率(秒),默认 0.2



Expand Down
4 changes: 4 additions & 0 deletions portable_config/script-opts/thumbfast.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ network=no
# 是否对音频文件启用,默认 no
audio=no

# 是否只对时长高于该值的视频启用(秒),默认 0 即禁用
min_duration=0
# 是否使用高精度的预览,默认 yes
precise=yes
# 是否使用硬解加速,默认 yes
hwdec=yes
# 解码频率(秒),默认 0.2
frequency=0.2
9 changes: 6 additions & 3 deletions portable_config/scripts/thumbfast.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ local options = {
network = false, -- Enable on network playback
audio = false, -- Enable on audio playback

min_duration = 0, -- 对短视频关闭预览(秒)
precise = true, -- 启用高精度的预览
hwdec = true, -- 启用硬解加速
frequency = 0.2, -- 解码频率(秒)

}

Expand Down Expand Up @@ -296,7 +298,7 @@ local function seek()
end
end

local seek_period = 0.2
local seek_period = options.frequency
local seek_timer = mp.add_timeout(seek_period, seek)
seek_timer:kill()
local function request_seek()
Expand Down Expand Up @@ -417,10 +419,11 @@ local function file_load()
last_seek_time = nil

network = mp.get_property_bool("demuxer-via-network", false)
local image = mp.get_property_native('current-tracks/video/image', true)
local image = mp.get_property_native("current-tracks/video/image", true)
local albumart = image and mp.get_property_native("current-tracks/video/albumart", false)
local short_video = mp.get_property_native("duration", 0) <= options.min_duration

disabled = (network and not options.network) or (albumart and not options.audio) or (image and not albumart)
disabled = (network and not options.network) or (albumart and not options.audio) or (image and not albumart) or (short_video and options.min_duration > 0)
calc_dimensions()
info(effective_w, effective_h)
if disabled then return end
Expand Down

0 comments on commit 925934c

Please sign in to comment.