Spaces:
Build error
Build error
Commit
·
5f5a645
1
Parent(s):
53b9cd0
Create utils.py
Browse files- components/utils.py +20 -0
components/utils.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from moviepy.editor import VideoFileClip, concatenate_videoclips,vfx
|
| 2 |
+
|
| 3 |
+
def combine_videos(folder_name):
|
| 4 |
+
|
| 5 |
+
length = len(os.listdir(folder_name))
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
combined = concatenate_videoclips(
|
| 9 |
+
[VideoFileClip(os.path.join(folder_name,x)).subclip(0,7).fx(vfx.fadein,0.5).fx(vfx.fadeout,0.5) for x in sorted(os.listdir(folder_name))],
|
| 10 |
+
"compose",bg_color=None, padding=0
|
| 11 |
+
)
|
| 12 |
+
combined.write_videofile(os.path.join(folder_name, "Final_Ad_Video.mp4"))
|
| 13 |
+
|
| 14 |
+
# if length <= 6:
|
| 15 |
+
# combined = concatenate_videoclips([VideoFileClip(os.path.join(folder_name,x)).subclip(0,10) for x in os.listdir(folder_name)])
|
| 16 |
+
# combined.write_videofile(os.path.join(folder_name, "Ad_Video.mp4"))
|
| 17 |
+
# else :
|
| 18 |
+
# combined = concatenate_videoclips([VideoFileClip(os.path.join(folder_name,x)).subclip(0,60//length) for x in os.listdir(folder_name)])
|
| 19 |
+
# combined.write_videofile(os.path.join(folder_name, "Ad_Video.mp4"))
|
| 20 |
+
print("Done! Your ads video has been created")
|