Spaces:
Runtime error
Runtime error
yiyixuxu
commited on
Commit
·
2f49504
1
Parent(s):
c7d5df4
testing
Browse files
app.py
CHANGED
@@ -53,7 +53,7 @@ def process_video_parallel(video, skip_frames, dest_path, num_processes, process
|
|
53 |
cap = cv2.VideoCapture(video)
|
54 |
chunks_per_process = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) // (num_processes * skip_frames)
|
55 |
count = skip_frames * chunks_per_process * process_number
|
56 |
-
print(f"worker: {process_number}, process frames {count} ~ {skip_frames * chunks_per_process * (process_number + 1)}")
|
57 |
while count < skip_frames * chunks_per_process * (process_number + 1) :
|
58 |
cap.set(cv2.CAP_PROP_POS_FRAMES, count)
|
59 |
ret, frame = cap.read()
|
@@ -91,9 +91,9 @@ def vid2frames(url, sampling_interval=1, ext='mp4'):
|
|
91 |
# testing..
|
92 |
cap = cv2.VideoCapture(video)
|
93 |
print(f'video: {video}; isOpen? : {cap.isOpened()}')
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
return dest_path
|
98 |
|
99 |
|
|
|
53 |
cap = cv2.VideoCapture(video)
|
54 |
chunks_per_process = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) // (num_processes * skip_frames)
|
55 |
count = skip_frames * chunks_per_process * process_number
|
56 |
+
print(f"worker: {process_number}, process frames {count} ~ {skip_frames * chunks_per_process * (process_number + 1)} \n total number of frames: {cap.get(cv2.CAP_PROP_FRAME_COUNT)} \n video: {video}; isOpen? : {cap.isOpened()}")
|
57 |
while count < skip_frames * chunks_per_process * (process_number + 1) :
|
58 |
cap.set(cv2.CAP_PROP_POS_FRAMES, count)
|
59 |
ret, frame = cap.read()
|
|
|
91 |
# testing..
|
92 |
cap = cv2.VideoCapture(video)
|
93 |
print(f'video: {video}; isOpen? : {cap.isOpened()}')
|
94 |
+
print(f'n_workers: {n_workers}')
|
95 |
+
with Pool(n_workers) as pool:
|
96 |
+
pool.map(partial(process_video_parallel, video, skip_frames, dest_path, n_workers), range(n_workers))
|
97 |
return dest_path
|
98 |
|
99 |
|