Rahatara's picture
Update app2.py
071fff8 verified
raw
history blame contribute delete
895 Bytes
import cv2
import gradio as gr
# get the frames
def frame_capture(video_path):
# Function to extract frames
vidObj = cv2.VideoCapture(video_path)
# Used as counter variable
count = 0
frames = []
# checks whether frames were extracted
success = 1
while success:
# vidObj object calls read
# function to extract frames
success, image = vidObj.read()
# Append the frame to the list
if success:
frames.append(image)
count += 1
return frames
def extract_frames(video):
frames = frame_capture(video)
return frames
# Define the Gradio interface
video_input = gr.Video(label="Upload Video", autoplay=True)
output_frames = gr.Gallery(label='Frame')
# Create the Gradio app
gr.Interface(fn=extract_frames, inputs=video_input, outputs=output_frames, title='Video Frame Extractor').launch()