Test_Video / app.py
ParthCodes's picture
Update app.py
1e3589d verified
raw
history blame
653 Bytes
import gradio as gr
import cv2
import moviepy.editor as mpe
from moviepy.editor import VideoFileClip
def process(video_path):
print(video_path)
clip = mpe.VideoFileClip(video_path)
clip.write_videofile('mp4file.mp4', fps=60)
cap = cv2.VideoCapture('mp4file.mp4')
fps = int(cap.get(cv2.CAP_PROP_FPS))
total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
interval = int(fps/2)
print(interval, total_frames)
return interval, total_frames
demo = gr.Interface(fn=process, inputs=gr.Video(format='mp4'), outputs=["textbox", "textbox"], title="Video Frame Counter")
if __name__ == "__main__":
demo.launch()