Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
doanaktar opened this issue Jul 10, 2023 · 4 comments
Open

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

doanaktar opened this issue Jul 10, 2023 · 4 comments
Labels
images Related to ImageClip, or handling of images in general. question Questions regarding functionality, usage video Related to VideoClip and related classes, or handling of video in general.

Comments

@doanaktar
Copy link

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")
@doanaktar doanaktar added the question Questions regarding functionality, usage label Jul 10, 2023
@keikoro keikoro added video Related to VideoClip and related classes, or handling of video in general. images Related to ImageClip, or handling of images in general. labels Jul 11, 2023
@TheHimanshuRastogi
Copy link

Show both videos for better help.

@Good0007
Copy link

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')

@jitendra-koodo
Copy link

jitendra-koodo commented Aug 12, 2024

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')

This does not show the background video. Transparency does not seem to work.

webm video : https://rotato.netlify.app/alpha-demo/movie-webm.webm

See web view showing transparency: https://codepen.io/mortenjust/pen/BaLrjzm

Any solution/work around?

@BackrndSource
Copy link

If you install the Pull Request #2229 , or you wait until the approval and update of moviepy, you can set parameters decoder="libvpx-vp9" and has_mask=True in VideoFIleClip like this:

from moviepy.editor import VideoFileClip, CompositeVideoClip
[...]
clip2 = VideoFileClip("transparent.webm", has_mask=True, decoder="libvpx-vp9")
[...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
images Related to ImageClip, or handling of images in general. question Questions regarding functionality, usage video Related to VideoClip and related classes, or handling of video in general.
Projects
None yet
Development

No branches or pull requests

6 participants