File size: 1,067 Bytes
8d2001a
7081512
8d2001a
 
 
 
 
 
 
 
86f6646
8d2001a
 
af45f7f
86f6646
 
8d2001a
68a5c33
8d2001a
af45f7f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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()