Home Video editing with python : adding a background music to a video with sound
Reply: 1

Video editing with python : adding a background music to a video with sound

Jay D.
1#
Jay D. Published in 2018-02-11 04:02:23Z

I would like to add a background music to a video file (.mp4) in python.

I have looked the web and did some tricks with moviepy for python, but I did not found a single way to add background music to a video file that already contains music. Any ideas how to do that ?

Edit following Anil_M's comment : Thanks, no I didn't look at this particular thread, althought I knew about ffmpeg but it looks like again, it is a way to merge a video without audio with an audio track.

So now I am going to try to extract audio from the video, merge with another audio file, then merge back with video. Maybe that's not the best way, but at least it is possile as questions about merging 2 audio tracks are answered.

Zulko
2#
Zulko Reply to 2018-02-19 12:50:10Z

You can do this with moviepy's CompositeAudioClip:

import moviepy.editor as mpe
my_clip = mpe.VideoFileClip('some_clip.mp4')
audio_background = mpe.AudioFileClip('some_background.mp3')
final_audio = mpe.CompositeAudioClip([my_clip.audio, audio_background])
final_clip = my_clip.set_audio(final_audio)
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.426281 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO