0

So I'm trying to create a clip with moviepy where five semi-transparent clips are overlaid on each other using the CompositeVideoClip.

The output should be a clip of length equal to the longest clip, where the all the layers of the composite clip are visible.

My code looks something like this:

from moviepy.editor import *

clip_1 = VideoFileClip('some\\path\\here.mp4')
clip_2 = VideoFileClip('some\\path\\here.mp4')
clip_3 = VideoFileClip('some\\path\\here.mp4')
clip_4 = VideoFileClip('some\\path\\here.mp4')
clip_5 = VideoFileClip('some\\path\\here.mp4')

list_of_clips = [clip_1, clip_2, clip_3, clip_4, clip_5]

for index, clip in enumerate(list_of_clips):
    list_of_clips[index] = clip.set_opacity(.20)

output_clip = CompositeVideoClip(list_of_clips)

output_clip.write_videofile('some\\path\\here.mp4')

Code runs fine, except transparency is not applied.

Neither does this work:

clip = VideoFileClip(some\\path\\here.mp4).set_opacity(.30)

clip.write_videofile(some\\path\\here.mp4)

Export works fine, but clip is fully opaque.

Any suggestions for how to achieve transparency in clip outputs?

dequation
  • 531
  • 5
  • 4

1 Answers1

0

the mp4 (I'm assuming h264) format does not offer transparency. webM (vp9) and some variants of h265 do offer transparency.

Im not sure exactly what you are trying to do - but perhaps creating the overlaid videos as webm (transparency supported) - and then converting to h264 at the end might work for you.

Doug Sillars
  • 1,625
  • 5
  • 7