Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,34 @@
|
|
1 |
import gradio as gr
|
2 |
from modeler import SfM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
|
5 |
def make_model(vid_path):
|
|
|
1 |
import gradio as gr
|
2 |
from modeler import SfM
|
3 |
+
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
|
4 |
+
from pytube import YouTube
|
5 |
+
|
6 |
+
|
7 |
+
def load_video_yt(vid):
|
8 |
+
yt = YouTube(vid)
|
9 |
+
vid = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download(filename=f"{uid}-tmp.mp4")
|
10 |
+
vid_aud = yt.streams.filter(only_audio=True)[0].download(filename=f"{uid}-tmp_aud.mp4")
|
11 |
+
print (f'Video Length: {yt.length}')
|
12 |
+
return vid, vid_aud, f"{uid}-tmp_aud.mp4"
|
13 |
+
|
14 |
+
def trim_vid():
|
15 |
+
ffmpeg_extract_subclip("video1.mp4", start_time, end_time, targetname="test.mp4")
|
16 |
+
|
17 |
+
|
18 |
+
def trim_clip(clip, start_t, end_t):
|
19 |
+
clip = Path(f"{uid}-tmp_aud.mp4")
|
20 |
+
song = AudioSegment.from_file(f"{uid}-tmp_aud.mp4", format="mp4")
|
21 |
+
start_min = int(start_t.split(":",1)[0])
|
22 |
+
start_sec = int(start_t.split(":",1)[1])
|
23 |
+
end_min = int(end_t.split(":",1)[0])
|
24 |
+
end_sec = int(end_t.split(":",1)[1])
|
25 |
+
start = ((start_min*60)+start_sec)*1000
|
26 |
+
end = ((end_min*60)+end_sec)*1000
|
27 |
+
song_clip = song[start: end]
|
28 |
+
song_clip.export(f"{uid}-trim.wav", format="wav")
|
29 |
+
print("New Audio file is created and saved")
|
30 |
+
|
31 |
+
return f"{uid}-trim.wav"
|
32 |
|
33 |
|
34 |
def make_model(vid_path):
|