79705940

Date: 2025-07-18 09:14:40
Score: 1
Natty:
Report link

from moviepy.editor import VideoFileClip, AudioFileClip

# File paths (change these to match your files)

video_path = "WhatsApp Video 2025-07-18 at 12.56.17_05e0168d.mp4"

extracted_audio_path = "extracted_audio.mp3"

output_video_path = "video_with_background_music.mp4"

# Load the video

video = VideoFileClip(video_path)

# Extract the audio

audio = video.audio

audio.write_audiofile(extracted_audio_path)

# Remove original audio from video

video_no_audio = video.without_audio()

# Load extracted audio as new background music

clean_audio = AudioFileClip(extracted_audio_path)

final_video = video_no_audio.set_audio(clean_audio)

# Export the final video

final_video.write_videofile(output_video_path, codec='libx264', audio_codec='aac')

print("✅ Done! Your new video is saved as:", output_video_path)

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: omsai zeroxandtyping