Program 1 : Combine Two Audio Files in to One Audio File using Python MoviePy || Concatenate Two Audio Files
# combine two audio files into one using python moviepy
from moviepy.editor import concatenate_audioclips, AudioFileClip
input_audio1 = AudioFileClip("audio1.mp3")
input_audio2 = AudioFileClip("audio2.mp3")
final_audio = concatenate_audioclips([input_audio1, input_audio2])
final_audio.write_audiofile("output.mp3")
Program 2 : Adding Background Music to your Video using Python MoviePy Audio Length is greater than Video Length
# Adding Background Music to Video - Audio Length > Video Length
from moviepy.editor import AudioFileClip, VideoFileClip, CompositeAudioClip
input_video_clip = VideoFileClip("video.mp4")
input_audio_clip = AudioFileClip("audio.mp3")
duration = input_video_clip.duration
temp_audio_clip = input_audio_clip.set_duration(duration)
final_audio_clip = CompositeAudioClip([temp_audio_clip])
final = input_video_clip.set_audio(final_audio_clip)
final.write_videofile("output.mp4",fps=60)
Program 3 : Cut Audio File in to Sub clips using Python MoviePy Editor || Create Sub clip of an audio file
# cut audio in to sub clip and store them using python moviepy
from moviepy.editor import AudioFileClip
input_audio_clip = AudioFileClip("audio1.mp3")
final_clip = input_audio_clip.subclip(30, 60)
final_clip.write_audiofile("output.mp3")
Program 4 : Cut video in to sub clip and store them using python moviepy
# Cut video in to sub clip and store them using python moviepy
from moviepy.editor import VideoFileClip
input_video = VideoFileClip("video.mp4")
final_clip = input_video.subclip(0, 29)
final_clip.write_videofile("output.mp4", fps=60)
0 Comments