(source_dir: os.PathLike, target_dir: os.PathLike, num_workers: int, video_ext: str, **process_video_kwargs)
| 17 | |
| 18 | |
| 19 | def 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 | |
| 40 | def task_proxy(kwargs): |
no test coverage detected