@@ -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,7 @@ 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 not args . no_cache and (arr := levels .read_cache ("audio" , (obj ["stream" ],))) is not None :
135
134
print_arr (arr )
136
135
else :
137
136
container = bv .open (src .path , "r" )
@@ -148,11 +147,12 @@ def value_storing_generator() -> Iterator[np.float32]:
148
147
container .close ()
149
148
150
149
cache_array = np .array (values , dtype = np .float32 )
151
- levels .cache (cache_array , "audio" , (obj ["stream" ],))
150
+ if not args .no_cache :
151
+ levels .cache (cache_array , "audio" , (obj ["stream" ],))
152
152
153
153
elif method == "motion" :
154
154
mobj = (obj ["stream" ], obj ["width" ], obj ["blur" ])
155
- if (arr := levels .read_cache ("motion" , mobj )) is not None :
155
+ if not args . no_cache and (arr := levels .read_cache ("motion" , mobj )) is not None :
156
156
print_arr (arr )
157
157
else :
158
158
container = bv .open (src .path , "r" )
@@ -171,7 +171,8 @@ def value_storing_generator() -> Iterator[np.float32]:
171
171
container .close ()
172
172
173
173
cache_array = np .array (values , dtype = np .float32 )
174
- levels .cache (cache_array , "motion" , mobj )
174
+ if not args .no_cache :
175
+ levels .cache (cache_array , "motion" , mobj )
175
176
176
177
elif method == "subtitle" :
177
178
print_arr (levels .subtitle (** obj ))
0 commit comments