-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
48 lines (38 loc) · 1.47 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from moviepy.editor import *
# Function to add video source
def add_video_source(clip, video_source):
video_clip = VideoFileClip(video_source)
video_clip = video_clip.resize(clip.size)
return video_clip.set_duration(clip.duration)
# Function to add audio source
def add_audio_source(clip, audio_source):
audio_clip = AudioFileClip(audio_source)
return clip.set_audio(audio_clip)
# Function to apply visual 3D effect
def apply_3d_effect(clip):
return clip.fx(vfx.volumetric)
# Function to apply pitch helper
def apply_pitch_helper(clip):
return clip.fx(audio.audio_fadein, 0.5).fx(audio.audio_fadeout, 0.5).fx(audio.speedx, 1.5)
# Function to apply screen flip
def apply_screen_flip(clip):
return clip.fx(vfx.mirror_x)
# Function to generate YTPMV
def generate_ytpmv(video_source, audio_source, output_path):
# Load video clip
clip = VideoFileClip(video_source)
# Add video and audio sources
clip = add_video_source(clip, video_source)
clip = add_audio_source(clip, audio_source)
# Apply effects
clip = apply_3d_effect(clip)
clip = apply_pitch_helper(clip)
clip = apply_screen_flip(clip)
# Write the final video
clip.write_videofile(output_path, codec='libx264')
# Example usage
if __name__ == "__main__":
video_source = "input_video.mp4"
audio_source = "input_audio.mp3"
output_path = "output_ytpmv.mp4"
generate_ytpmv(video_source, audio_source, output_path)