I'm using moviepy, PIL and numpy and trying to compile a video with 3 components : A background image that is a PNG with no transparency, an Overlay Video that is a HEVC with Alpha, and a primary clip that is produced with a collection of PNG images with transparency.
The video is composed with background + overlay video + main video.
The problem I'm having is that the overlay video has a black background, so the background image is covered completely. Moviepy is able to import the HEVC video successfully by it seems as though the Alpha channel is lost on import.
Any ideas?
Here's my code :
from PIL import Image
import moviepy.editor as mpe
import numpy as np
def CompileVideo() :
frames = ["list_of_png_files_with_transparency"]
fps = 30.0
clips = [mpe.ImageClip(np.asarray(Image.open(frame))).set_duration(1 / int(fps)) for frame in frames]
ad_clip = mpe.concatenate_videoclips(clips, method="compose")
bg_clip = mpe.ImageClip(np.asarray(Image.open("path_to_background_file_no_transparency"))).set_duration(ad_clip.duration)
overlay_clip = mpe.VideoFileClip("path_to_HEVC_with_Alpha.mov")
comp = [bg_clip, overlay_clip, ad_clip]
final = mpe.CompositeVideoClip(comp).set_duration(ad_clip.duration)
final.write_videofile("output.mp4", fps=fps)