fffiloni's picture
Update app.py
86f6646
raw
history blame
1.07 kB
import gradio as gr
from scenedetect import SceneManager, open_video, detect, ContentDetector, video_splitter, split_video_ffmpeg
def find_scenes(video_path, threshold=27.0):
video = open_video(video_path)
scene_manager = SceneManager()
scene_manager.add_detector(
ContentDetector(threshold=threshold))
# Detect all scenes in video from current position to end.
scene_manager.detect_scenes(video)
scene_list = scene_manager.get_scene_list()
# `get_scene_list` returns a list of start/end timecode pairs
# for each scene that was found.
split_list = video_splitter.split_video_ffmpeg(video_path, scene_list, output_file_template='$VIDEO_NAME-Scene-$SCENE_NUMBER.mp4', video_name=None, arg_override='-c:v libx264 -preset fast -crf 21 -c:a aac', show_progress=False, show_output=False, suppress_output=None, hide_progress=None)
return scene_list, split_list
video_input=gr.Video(source="upload", format="mp4", mirror_webcam="False");
gr.Interface(fn=find_scenes, inputs=video_input, outputs=["json", "video"]).launch()