@@ -36,6 +36,7 @@ class LevelArgs:
36
36
input : list [str ] = field (default_factory = list )
37
37
edit : str = "audio"
38
38
timebase : Fraction | None = None
39
+ no_cache : bool = False
39
40
help : bool = False
40
41
41
42
@@ -53,16 +54,14 @@ def levels_options(parser: ArgumentParser) -> ArgumentParser:
53
54
type = frame_rate ,
54
55
help = "Set custom timebase" ,
55
56
)
57
+ parser .add_argument ("--no-cache" , flag = True )
56
58
return parser
57
59
58
60
59
61
def print_arr (arr : NDArray ) -> None :
60
62
print ("" )
61
63
print ("@start" )
62
- if arr .dtype in {np .float64 , np .float32 , np .float16 }:
63
- for a in arr :
64
- sys .stdout .write (f"{ a :.20f} \n " )
65
- elif arr .dtype == np .bool_ :
64
+ if arr .dtype == np .bool_ :
66
65
for a in arr :
67
66
sys .stdout .write (f"{ 1 if a else 0 } \n " )
68
67
else :
@@ -76,7 +75,7 @@ def print_arr_gen(arr: Iterator[float | np.float32]) -> None:
76
75
print ("" )
77
76
print ("@start" )
78
77
for a in arr :
79
- print (f"{ a :.20f } " )
78
+ print (f"{ a } " )
80
79
print ("" )
81
80
82
81
@@ -131,7 +130,11 @@ def main(sys_args: list[str] = sys.argv[1:]) -> None:
131
130
levels = initLevels (src , tb , bar , False , log )
132
131
try :
133
132
if method == "audio" :
134
- if (arr := levels .read_cache ("audio" , (obj ["stream" ],))) is not None :
133
+ if (
134
+ not args .no_cache
135
+ and (arr := levels .read_cache ("audio" , (obj ["stream" ],)))
136
+ is not None
137
+ ):
135
138
print_arr (arr )
136
139
else :
137
140
container = bv .open (src .path , "r" )
@@ -148,11 +151,15 @@ def value_storing_generator() -> Iterator[np.float32]:
148
151
container .close ()
149
152
150
153
cache_array = np .array (values , dtype = np .float32 )
151
- levels .cache (cache_array , "audio" , (obj ["stream" ],))
154
+ if not args .no_cache :
155
+ levels .cache (cache_array , "audio" , (obj ["stream" ],))
152
156
153
157
elif method == "motion" :
154
158
mobj = (obj ["stream" ], obj ["width" ], obj ["blur" ])
155
- if (arr := levels .read_cache ("motion" , mobj )) is not None :
159
+ if (
160
+ not args .no_cache
161
+ and (arr := levels .read_cache ("motion" , mobj )) is not None
162
+ ):
156
163
print_arr (arr )
157
164
else :
158
165
container = bv .open (src .path , "r" )
@@ -171,7 +178,8 @@ def value_storing_generator() -> Iterator[np.float32]:
171
178
container .close ()
172
179
173
180
cache_array = np .array (values , dtype = np .float32 )
174
- levels .cache (cache_array , "motion" , mobj )
181
+ if not args .no_cache :
182
+ levels .cache (cache_array , "motion" , mobj )
175
183
176
184
elif method == "subtitle" :
177
185
print_arr (levels .subtitle (** obj ))
0 commit comments