Spaces:
Runtime error
Runtime error
File size: 1,255 Bytes
5f5a645 0fcaddf 5f5a645 e855c02 5f5a645 e855c02 5f5a645 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from moviepy.editor import VideoFileClip, concatenate_videoclips,vfx
import os
def combine_videos(folder_name):
length = len(os.listdir(folder_name))
vids = [VideoFileClip(os.path.join(folder_name,x)) for x in sorted(os.listdir(folder_name))]
combined = concatenate_videoclips(
[vid.subclip(0,7).fx(vfx.fadein,0.5).fx(vfx.fadeout,0.5) if vid.duration > 7 else vid.fx(vfx.fadein,0.5).fx(vfx.fadeout,0.5) for vid in vids],
# [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))],
"compose",bg_color=None, padding=0
)
combined.write_videofile(os.path.join(folder_name, "Final_Ad_Video.mp4"))
# if length <= 6:
# combined = concatenate_videoclips([VideoFileClip(os.path.join(folder_name,x)).subclip(0,10) for x in os.listdir(folder_name)])
# combined.write_videofile(os.path.join(folder_name, "Ad_Video.mp4"))
# else :
# combined = concatenate_videoclips([VideoFileClip(os.path.join(folder_name,x)).subclip(0,60//length) for x in os.listdir(folder_name)])
# combined.write_videofile(os.path.join(folder_name, "Ad_Video.mp4"))
print("Done! Your ads video has been created") |