forked from mfcc64/mpv-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVideoTek.lua
More file actions
139 lines (82 loc) · 3 KB
/
VideoTek.lua
File metadata and controls
139 lines (82 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
-- various audio visualization
local opts = {
mode = "force",
-- off disable visualization
-- force always enable visualization
name = "off",
-- off
-- tektronix
quality = "medium",
-- medium
}
-- key bindings
-- cycle visualizer
local cycle_key = "y"
if not (mp.get_property("options/lavfi-complex", "") == "") then
return
end
local visualizer_name_list = {
"off",
"tektronix",
}
local options = require 'mp.options'
local msg = require 'mp.msg'
options.read_options(opts)
local function get_visualizer(name)
-- Here we define the Graph
if name == "tektronix" then
return "color=c=black:s=1280x720[black];[vid1]split=3[v1][v2][v3];[aid1]asplit[a1][a2];[a1]avectorscope=s=240x160:zoom=2:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7[avect-out];[a2]showvolume=r=25:w=140:h=10:t=0:f=0.9[vol-out];[v1]scale=640x360[v1-o];[v2]hflip,waveform=m=1:d=0:r=1:c=7,scale=640x360,setsar=1,hflip[v2-o];[v3]vectorscope=m=0:g=green,scale=300x300,setsar=1[vect];[black][v1-o]overlay=0:0[q1];[q1][vol-out]overlay=640:0[q2];[q2][v2-o]overlay=0:360[q3];[q3][avect-out]overlay=1000:490[q4];[q4][vect]overlay=700:390[q5];[q5] setpts=PTS [vo]"
elseif name == "off" then
return "[aid1] asetpts=PTS [ao]; [vid1] setpts=PTS [vo]"
end
msg.log("error", "invalid visualizer name")
return ""
end
local function select_visualizer(atrack, vtrack, albumart)
if opts.mode == "off" then
return ""
elseif opts.mode == "force" then
return get_visualizer(opts.name)
end
msg.log("error", "invalid mode")
return ""
end
local function visualizer_hook()
local count = mp.get_property_number("track-list/count", -1)
local atrack = 0
local vtrack = 0
local albumart = 0
if count <= 0 then
return
end
for tr = 0,count-1 do
if mp.get_property("track-list/" .. tr .. "/type") == "audio" then
atrack = atrack + 1
else
if mp.get_property("track-list/" .. tr .. "/type") == "video" then
if mp.get_property("track-list/" .. tr .. "/albumart") == "yes" then
albumart = albumart + 1
else
vtrack = vtrack + 1
end
end
end
end
mp.set_property("options/lavfi-complex", select_visualizer(atrack, vtrack, albumart))
end
mp.add_hook("on_preloaded", 50, visualizer_hook)
local function cycle_visualizer()
local i, index = 1
for i = 1, #visualizer_name_list do
if (visualizer_name_list[i] == opts.name) then
index = i + 1
if index > #visualizer_name_list then
index = 1
end
break
end
end
opts.name = visualizer_name_list[index]
visualizer_hook()
end
mp.add_key_binding(cycle_key, "cycle-visualizer", cycle_visualizer)