MCPcopy
hub / github.com/Vchitect/Latte / convert_videos_to_frames

Function convert_videos_to_frames

tools/convert_videos_to_frames.py:19–37  ·  view source on GitHub ↗
(source_dir: os.PathLike, target_dir: os.PathLike, num_workers: int, video_ext: str, **process_video_kwargs)

Source from the content-addressed store, hash-verified

17
18
19def convert_videos_to_frames(source_dir: os.PathLike, target_dir: os.PathLike, num_workers: int, video_ext: str, **process_video_kwargs):
20 broken_clips_dir = f'{target_dir}_broken_clips'
21 os.makedirs(target_dir, exist_ok=True)
22 os.makedirs(broken_clips_dir, exist_ok=True)
23
24 clips_paths = [cp for cp in listdir_full_paths(source_dir) if cp.endswith(video_ext)]
25 clips_fps = []
26 tasks_kwargs = [dict(
27 clip_path=cp,
28 target_dir=target_dir,
29 broken_clips_dir=broken_clips_dir,
30 **process_video_kwargs,
31 ) for cp in clips_paths]
32 pool = Pool(processes=num_workers)
33
34 for fps in tqdm(pool.imap_unordered(task_proxy, tasks_kwargs), total=len(clips_paths)):
35 clips_fps.append(fps)
36
37 print(f'All possible fps: {Counter(clips_fps).most_common()}')
38
39
40def task_proxy(kwargs):

Callers 1

Calls 2

listdir_full_pathsFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected