moviepy icon indicating copy to clipboard operation
moviepy copied to clipboard

CompositeVideoClip with CompositeVideoClip ignores alpha channel

Open samikhailov opened this issue 2 years ago • 1 comments

Expected Behavior

When using a CompositeVideoClip that contains another CompositeVideoClip containing an image with an alpha channel, transparency works correctly.

Actual Behavior

When using a CompositeVideoClip that contains another CompositeVideoClip containing an image with an alpha channel, the transparent part is filled with black.

Steps to Reproduce the Problem

bg_cl = VideoFileClip("path.mp4")
image_cl = ImageClip("image.png")  # an image with alpha channel 
union_cl = CompositeVideoClip([bg_cl, image_cl]).with_duration(3)
union_cl.write_videofile("ok.mp4", fps=3, codec="libx264", threads=4)

result_cl = CompositeVideoClip([union_cl])
result_cl.write_videofile("not_ok.mp4", fps=3, codec="libx264", threads=4)

ok.mp4 ok.mp4 not_ok.mp4 not_ok.mp4

Specifications

  • Python Version: 3.9.16
  • MoviePy Version: 2.0.0.dev0 @69ac313
  • Platform Name: macOS
  • Platform Version: Ventura 13.2.1

Extra

There is no problem in the MoviePy v1 in this part.

samikhailov avatar May 22 '23 12:05 samikhailov

If I add the use_bgclip=True flag, then the background of the image becomes transparent.

union_cl = CompositeVideoClip([bg, image_cl], use_bgclip=True).with_duration(3)

samikhailov avatar May 22 '23 13:05 samikhailov