|
import gradio as gr |
|
|
|
from scenedetect import open_video, SceneManager, split_video_ffmpeg |
|
from scenedetect.detectors import ContentDetector |
|
from scenedetect.video_splitter import 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)) |
|
scene_manager.detect_scenes(video, show_progress=True) |
|
scene_list = scene_manager.get_scene_list() |
|
|
|
|
|
|
|
|
|
|
|
print(scene_list) |
|
shot_in = scene_list[0][0].get_frames() |
|
shot_out = scene_list[0][1].get_frames() |
|
print(shot_in, shot_out) |
|
return scene_list |
|
|
|
video_input=gr.Video(source="upload", format="mp4", mirror_webcam="False"); |
|
|
|
gr.Interface(fn=find_scenes, inputs=video_input, outputs="json").launch() |