-
Notifications
You must be signed in to change notification settings - Fork 0
/
VID.py
23 lines (20 loc) · 794 Bytes
/
VID.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import moviepy.editor as mp
import os
class Video:
def __init__(self, fileSelect):
self.fileSelect = fileSelect
def AddVideo(self):
video = mp.VideoFileClip("vid" + str(self.fileSelect) + ".mp4")
audio = mp.AudioFileClip("temp1.wav")
# Get the duration of the audio file
audio_duration = audio.duration
# Loop the video until the audio is complete
while video.duration < audio_duration:
video = mp.concatenate_videoclips([video, video])
# Set the audio of the video
final = video.set_audio(audio)
final = final.subclip(0, audio_duration)
# Write the final video file
final.write_videofile("BrainRot.mp4")
os.remove("temp1.wav")
return 0