Spaces:
Sleeping
Sleeping
import gradio as gr | |
from scenedetect import SceneManager, open_video, detect, ContentDetector, 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) | |
# `get_scene_list` returns a list of start/end timecode pairs | |
# for each scene that was found. | |
split_list=scenedetect.video_splitter.split_video_ffmpeg(input_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_manager.get_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() |