Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,17 +2,14 @@ import gradio as gr
|
|
| 2 |
from video2images import Video2Images
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
def extract_frames(
|
| 6 |
# Temporary directory to store frames
|
| 7 |
temp_dir = "temp_frames"
|
| 8 |
os.makedirs(temp_dir, exist_ok=True)
|
| 9 |
-
#
|
| 10 |
-
video_filepath = os.path.join(temp_dir, "uploaded_video.mp4")
|
| 11 |
-
video_file.save(video_filepath)
|
| 12 |
-
# Use the path of the uploaded video for extracting frames
|
| 13 |
out_filepath = os.path.join(temp_dir, "extracted_frames")
|
| 14 |
# Create Video2Images object
|
| 15 |
-
v2i = Video2Images(
|
| 16 |
# Extract frames
|
| 17 |
v2i.start()
|
| 18 |
return out_filepath # Return the directory where frames are saved
|
|
|
|
| 2 |
from video2images import Video2Images
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
def extract_frames(video_path):
|
| 6 |
# Temporary directory to store frames
|
| 7 |
temp_dir = "temp_frames"
|
| 8 |
os.makedirs(temp_dir, exist_ok=True)
|
| 9 |
+
# Use the provided video path for extracting frames
|
|
|
|
|
|
|
|
|
|
| 10 |
out_filepath = os.path.join(temp_dir, "extracted_frames")
|
| 11 |
# Create Video2Images object
|
| 12 |
+
v2i = Video2Images(video_path, out_dir=out_filepath)
|
| 13 |
# Extract frames
|
| 14 |
v2i.start()
|
| 15 |
return out_filepath # Return the directory where frames are saved
|