-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVideoFolderRepository.py
More file actions
40 lines (34 loc) · 1.6 KB
/
VideoFolderRepository.py
File metadata and controls
40 lines (34 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from pathlib import Path
import shutil
class VideoFolderRepository:
"""
Encapsulates access to files that describe a single uploaded video
(the video itself, its frames, metadata and translation results)
This repository assumes the video is stored in the local file system
in a single folder.
"""
def __init__(self, video_id: str, video_folder: Path):
self.video_id = video_id
self._video_folder = video_folder
# define common file paths
self.LOG_FILE = self.path("log.txt")
self.NORMALIZED_FILE = self.path("normalized_file.mp4") # always mp4
self.GEOMETRY_FILE = self.path("geometry.json")
self.CROPPED_LEFT_HAND_FOLDER = self.path("cropped_left_hand")
self.CROPPED_RIGHT_HAND_FOLDER = self.path("cropped_right_hand")
self.CROPPED_FACE_FOLDER = self.path("cropped_face")
self.CROPPED_IMAGES_FOLDER = self.path("cropped_images")
self.CLIPS_COLLECTION_FILE = self.path("clips_collection.json")
self.MAE_FEATURES_FILE = self.path("mae_features.npy")
self.S2V_FEATURES_FILE = self.path("s2v_features.npz")
self.DINO_FEATURES_FILE = self.path("dino_features.npy")
def path(self, repository_local_path: Path) -> Path:
"""Converts repo-local path to an actual, usable path"""
return self._video_folder / repository_local_path
@property
def root_path(self) -> Path:
"""Path to the folder representing this video repository"""
return self._video_folder
def remove(self):
if self.root_path.is_dir():
shutil.rmtree(self.root_path)