Spaces:
Runtime error
Runtime error
Commit
·
e2801bb
1
Parent(s):
6e951e6
Update components/utils.py
Browse files- components/utils.py +15 -3
components/utils.py
CHANGED
@@ -14,11 +14,23 @@ import os
|
|
14 |
|
15 |
def combine_videos(folder_name, length_speech):
|
16 |
|
17 |
-
length = len(os.listdir(folder_name))
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
combined = concatenate_videoclips(
|
24 |
[vid.subclip(0,ls).fx(vfx.fadein,0.5).fx(vfx.fadeout,0.5) if vid.duration > ls else vid.fx(vfx.fadein,0.5).fx(vfx.fadeout,0.5) for vid, ls in zip(vids, length_speech)],
|
|
|
14 |
|
15 |
def combine_videos(folder_name, length_speech):
|
16 |
|
17 |
+
# length = len(os.listdir(folder_name))
|
18 |
|
19 |
+
def check_len(dir):
|
20 |
+
if len(dir) < len(length_speech):
|
21 |
+
return check_len(dir*2)
|
22 |
+
else:
|
23 |
+
return dir
|
24 |
|
25 |
+
vid_dir = os.listdir(folder_name)
|
26 |
+
if len(vid_dir) == 0:
|
27 |
+
raise Exception("Canot find any video! Please try different words")
|
28 |
+
|
29 |
+
vid_dir = check_len(vid_dir)
|
30 |
+
|
31 |
+
vids = [VideoFileClip(os.path.join(folder_name,x)) for x in sorted(vid_dir)]
|
32 |
+
|
33 |
+
print(vids, len(vid_dir), len(length_speech))
|
34 |
|
35 |
combined = concatenate_videoclips(
|
36 |
[vid.subclip(0,ls).fx(vfx.fadein,0.5).fx(vfx.fadeout,0.5) if vid.duration > ls else vid.fx(vfx.fadein,0.5).fx(vfx.fadeout,0.5) for vid, ls in zip(vids, length_speech)],
|