Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
import gradio as gr
|
| 3 |
import cv2
|
| 4 |
import numpy as np
|
|
|
|
| 5 |
|
| 6 |
from scenedetect import open_video, SceneManager
|
| 7 |
from scenedetect.detectors import ContentDetector
|
|
@@ -25,7 +26,8 @@ def convert_to_tuple(list):
|
|
| 25 |
|
| 26 |
|
| 27 |
def find_scenes(video_path, threshold=27.0):
|
| 28 |
-
|
|
|
|
| 29 |
# Open our video, create a scene manager, and add a detector.
|
| 30 |
video = open_video(video_path)
|
| 31 |
scene_manager = SceneManager()
|
|
@@ -56,7 +58,7 @@ def find_scenes(video_path, threshold=27.0):
|
|
| 56 |
shot_out = shot[1].get_frames() / framerate
|
| 57 |
|
| 58 |
# Set name template for each shot
|
| 59 |
-
target_name = str(i+1)+"
|
| 60 |
|
| 61 |
# Split chunk
|
| 62 |
ffmpeg_extract_subclip(video_path, shot_in, shot_out, targetname=target_name)
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import cv2
|
| 4 |
import numpy as np
|
| 5 |
+
import os
|
| 6 |
|
| 7 |
from scenedetect import open_video, SceneManager
|
| 8 |
from scenedetect.detectors import ContentDetector
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
def find_scenes(video_path, threshold=27.0):
|
| 29 |
+
# file name without extension
|
| 30 |
+
print(os.path.splitext(video_path)[0])
|
| 31 |
# Open our video, create a scene manager, and add a detector.
|
| 32 |
video = open_video(video_path)
|
| 33 |
scene_manager = SceneManager()
|
|
|
|
| 58 |
shot_out = shot[1].get_frames() / framerate
|
| 59 |
|
| 60 |
# Set name template for each shot
|
| 61 |
+
target_name = str(os.path.splitext(video_path)[0]) + "_shot_" + str(i+1) + ".mp4"
|
| 62 |
|
| 63 |
# Split chunk
|
| 64 |
ffmpeg_extract_subclip(video_path, shot_in, shot_out, targetname=target_name)
|