AhmedIbrahim007 commited on
Commit
f42083a
·
verified ·
1 Parent(s): 5aa5bf2

Update extract_frames.py

Browse files
Files changed (1) hide show
  1. extract_frames.py +6 -3
extract_frames.py CHANGED
@@ -1,8 +1,11 @@
1
  import cv2
2
- import os , shutil
 
3
 
4
  def ExtractFrames(videoPath):
5
- shutil.rmtree("data/output")
 
 
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'frame_{frame_index:04d}.png')
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)