Spaces:
Runtime error
Runtime error
AhmedIbrahim007
commited on
Update extract_frames.py
Browse files- extract_frames.py +6 -3
extract_frames.py
CHANGED
@@ -1,8 +1,11 @@
|
|
1 |
import cv2
|
2 |
-
import os
|
|
|
3 |
|
4 |
def ExtractFrames(videoPath):
|
5 |
-
|
|
|
|
|
6 |
# Path to the video file
|
7 |
video_path = videoPath
|
8 |
|
@@ -32,7 +35,7 @@ def ExtractFrames(videoPath):
|
|
32 |
break
|
33 |
|
34 |
# Construct the filename for the frame
|
35 |
-
frame_filename = os.path.join(output_dir, f'
|
36 |
|
37 |
# Save the current frame as an image file
|
38 |
cv2.imwrite(frame_filename, frame)
|
|
|
1 |
import cv2
|
2 |
+
import os, shutil
|
3 |
+
|
4 |
|
5 |
def ExtractFrames(videoPath):
|
6 |
+
directory = "data/output"
|
7 |
+
if os.path.exists(directory):
|
8 |
+
shutil.rmtree(directory)
|
9 |
# Path to the video file
|
10 |
video_path = videoPath
|
11 |
|
|
|
35 |
break
|
36 |
|
37 |
# Construct the filename for the frame
|
38 |
+
frame_filename = os.path.join(output_dir, f'frames_{frame_index:04d}.png')
|
39 |
|
40 |
# Save the current frame as an image file
|
41 |
cv2.imwrite(frame_filename, frame)
|