import gradio as gr from video2images import Video2Images import os def extract_frames(video_path): # Temporary directory to store frames temp_dir = "temp_frames" os.makedirs(temp_dir, exist_ok=True) # Use the provided video path for extracting frames out_filepath = os.path.join(temp_dir, "extracted_frames") # Create Video2Images object v2i = Video2Images(video_path, out_dir=out_filepath) # Extract frames v2i.start() return out_filepath # Return the directory where frames are saved inputs = gr.Video(label="Upload Video") outputs = gr.Textbox(label="Output Directory") title = "Extract Frames from Video" description = "Upload a video file and extract frames from it." gr.Interface(fn=extract_frames, inputs=inputs, outputs=outputs, title=title, description=description).launch()