This repository has been archived by the owner on Mar 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pipeline.py
61 lines (47 loc) · 1.71 KB
/
pipeline.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from util import cleanDir, FileLocator
class ProcessingOperation:
"""
Interface for all video processing algorithms we add to our pipeline
"""
def process(self, file_locator: FileLocator, context: dict) -> None:
"""
:param file_locator: file locator to locate files and directories
:param context: processing context variables
:return: void return
"""
raise NotImplementedError()
def postProcess(self, file_locator: FileLocator) -> None:
"""
Post processing hook for algorithms that want to do things after the pipeline finishes
:return: void return
"""
return
class Pipeline:
"""
Video processing pipeline
"""
def __init__(self):
self.operations: list[ProcessingOperation] = []
self.context: dict = dict()
self.status = 0
def getProgress(self) -> (int, int):
return self.status, len(self.operations)
def addOperation(self, op: ProcessingOperation):
self.operations.append(op)
def processVideo(self, file_locator: FileLocator) -> None:
self.status = 0
for op in self.operations:
op.process(file_locator, self.context)
self.status += 1
for op in self.operations:
op.postProcess(file_locator)
# self.clean_up(file_locator)
return
# def clean_up(self, file_locator: FileLocator) -> None:
# ###
# # Cleans up all temporary directoraries.
# ###
# dirs = [file_locator.getAudioDirectory(), file_locator.getJsonDirectory(),
# file_locator.getIndexDirectory(), file_locator.getScreenshotDirectory()]
#
# [cleanDir(d) for d in dirs]