Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.1k stars 1.51k forks source link

Overlay video with .webm format video with transparent background #2008

Open doganaktarr opened 12 months ago

doganaktarr commented 12 months ago

Hello, I have a video in .webm format with a transparent background(clip2) and a normal mp4 video(clip1). I want to overlay clip2 video on clip1 video, but when I do that, the transparent feature in the background of clip2 disappears and a red beam of light comes on.

Here is my code:

from moviepy.editor import VideoFileClip, CompositeVideoClip
clip1 = VideoFileClip("test.mp4")
clip2 = VideoFileClip("transparent.webm")
clip2 = clip2.resize(0.25)

video = CompositeVideoClip([clip1,
                            clip2.set_position(("right","bottom"))])

video.write_videofile("my_concatenation.mp4")
TheHimanshuRastogi commented 12 months ago

Show both videos for better help.

Good0007 commented 6 months ago

You can set param: has_mask=True ,like this:


background = VideoFileClip("background.mp4")
layer = VideoFileClip("overlay.mov", has_mask=True)
CompositeVideoClip([background, layer]).write_videofile("out.mp4", codec='libx264')