Spaces:
Runtime error
Runtime error
yiyixuxu
commited on
Commit
•
12f763a
1
Parent(s):
f238f1a
skip_frames=1
Browse files
app.py
CHANGED
@@ -55,7 +55,8 @@ def process_video_parallel(video, skip_frames, dest_path, num_processes, process
|
|
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 |
-
|
|
|
59 |
ret, frame = cap.read()
|
60 |
if not ret:
|
61 |
break
|
@@ -85,6 +86,9 @@ def vid2frames(url, sampling_interval=1, ext='mp4'):
|
|
85 |
skip_frames = int(fps * sampling_interval)
|
86 |
except:
|
87 |
skip_frames = int(30 * sampling_interval)
|
|
|
|
|
|
|
88 |
print(f'video saved at: {video}, fps:{fps}, skip_frames: {skip_frames}')
|
89 |
# extract video frames at given sampling interval with multiprocessing -
|
90 |
print('extracting 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 |
+
if skip_frames > 1:
|
59 |
+
cap.set(cv2.CAP_PROP_POS_FRAMES, count)
|
60 |
ret, frame = cap.read()
|
61 |
if not ret:
|
62 |
break
|
|
|
86 |
skip_frames = int(fps * sampling_interval)
|
87 |
except:
|
88 |
skip_frames = int(30 * sampling_interval)
|
89 |
+
|
90 |
+
# testing
|
91 |
+
skip_frames = 1
|
92 |
print(f'video saved at: {video}, fps:{fps}, skip_frames: {skip_frames}')
|
93 |
# extract video frames at given sampling interval with multiprocessing -
|
94 |
print('extracting frames...')
|