@@ -123,6 +123,9 @@ def main(
123123 summary_interval : int = typer .Option (
124124 - 1 , help = "Interval in seconds to summarise the video."
125125 ),
126+ n_workers : int = typer .Option (
127+ 1 , help = "Number of workers to use. Default is 1. Use -1 to use all CPUs."
128+ ),
126129) -> None :
127130 """Default buffer is the perceptual hash buffer"""
128131 extractor_cfg = {}
@@ -169,6 +172,7 @@ def main(
169172 }
170173 ),
171174 extractor_config = extractor_cfg ,
175+ n_workers = n_workers ,
172176 )
173177 if ytdlp :
174178 video_path = _ytdlp_plugin (yt_extra_args , video_path , get_subs = subs_enable )
@@ -210,6 +214,9 @@ def buffer(
210214 yt_extra_args : str = typer .Option (
211215 None , help = "Extra arguments for YouTube-DLP extraction in classic format."
212216 ),
217+ n_workers : int = typer .Option (
218+ 1 , help = "Number of workers to use. Default is 1. Use -1 to use all CPUs."
219+ ),
213220):
214221 """Buffer type can be one of entropy, gzip, hash, passthrough"""
215222 cfg = SamplerConfig (
@@ -239,6 +246,7 @@ def buffer(
239246 "type" : "pass" ,
240247 }
241248 ),
249+ n_workers = n_workers ,
242250 )
243251 if ytdlp :
244252 video_path = _ytdlp_plugin (yt_extra_args , video_path )
@@ -278,6 +286,9 @@ def clip(
278286 yt_extra_args : str = typer .Option (
279287 None , help = "Extra arguments for YouTube-DLP extraction in classic format."
280288 ),
289+ n_workers : int = typer .Option (
290+ 1 , help = "Number of workers to use. Default is 1. Use -1 to use all CPUs."
291+ ),
281292):
282293 """Buffer type can be only of type hash when using CLIP gating."""
283294 if pos_samples is not None :
@@ -309,12 +320,37 @@ def clip(
309320 "model_name" : model_name ,
310321 "batch_size" : batch_size ,
311322 },
323+ n_workers = n_workers ,
312324 )
313325 if ytdlp :
314326 video_path = _ytdlp_plugin (yt_extra_args , video_path )
315327 _create_from_config (cfg = cfg , video_path = video_path , output_path = output_path )
316328
317329
330+ @app .command (name = "config" )
331+ def from_config (
332+ config_path : str = typer .Argument (..., help = "Path to the configuration file." ),
333+ video_path : str = typer .Argument (
334+ ..., help = "Path to the video file or a glob pattern."
335+ ),
336+ output_path : str = typer .Argument (..., help = "Path to the output folder." ),
337+ ytdlp : bool = typer .Option (
338+ False ,
339+ help = "Use yt-dlp to download videos from urls. Default is False."
340+ " Enabling this will treat video_path as an input to ytdlp command." ,
341+ ),
342+ yt_extra_args : str = typer .Option (
343+ None , help = "Extra arguments for YouTube-DLP extraction in classic format."
344+ ),
345+ ):
346+ """Create a sampler from a configuration file."""
347+
348+ cfg = SamplerConfig .from_yaml (config_path )
349+ if ytdlp :
350+ video_path = _ytdlp_plugin (yt_extra_args , video_path )
351+ _create_from_config (cfg = cfg , video_path = video_path , output_path = output_path )
352+
353+
318354def main_loop ():
319355 app ()
320356
0 commit comments