Spaces:
Sleeping
Sleeping
Create new file
Browse files
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from scenedetect import SceneManager, open_video, ContentDetector
|
| 3 |
+
|
| 4 |
+
def find_scenes(video_path, threshold=27.0):
|
| 5 |
+
video = open_video(video_path)
|
| 6 |
+
scene_manager = SceneManager()
|
| 7 |
+
scene_manager.add_detector(
|
| 8 |
+
ContentDetector(threshold=threshold))
|
| 9 |
+
# Detect all scenes in video from current position to end.
|
| 10 |
+
scene_manager.detect_scenes(video)
|
| 11 |
+
# `get_scene_list` returns a list of start/end timecode pairs
|
| 12 |
+
# for each scene that was found.
|
| 13 |
+
return scene_manager.get_scene_list()
|
| 14 |
+
|
| 15 |
+
video_input=gr.Video(source="upload", format="mp4");
|
| 16 |
+
|
| 17 |
+
gr.Interface(fn=find_scenes, inputs=video_input, outputs="json")
|