Zulko / moviepy

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

crossfadeout not effect after CompositeVideoClip #2138

Open verigle opened 3 months ago

verigle commented 3 months ago
from moviepy import *
concat_video_clip = CompositeVideoClip([clip1, clip2], size=(video_width, video_height))

concat_video_clip = concat_video_clip.crossfadeout(magic_time)

Expected Behavior

crossfadeout can effect on clip for concat_video_clip

Actual Behavior

crossfadeout not effect on clip for concat_video_clip

Steps to Reproduce the Problem

Specifications

harroopsra commented 1 week ago

Okay, I checked this. When written out, it does have a crossfadeout effect if it's followed by another clip. On its own (i.e. no clip following it), you're right in saying there is no effect. But that's not actually a bug.

If you check the documentation for fadeout, it has this comment

""" Makes the clip progressively fade to some color (black by default), over duration seconds at the end of the clip. Can be used for masks too, where the final color must be a number between 0 and 1. For cross-fading (progressive appearance or disappearance of a clip over another clip, see composition.crossfade """

Source: https://zulko.github.io/moviepy/_modules/moviepy/video/fx/fadeout.html#fadeout

Basically, cross-fading is only for progressive appearance or disappearance of a clip OVER ANOTHER. The function that you are actually looking for is fadeout if there is no clip to follow.

I tried to use your variable names. Here is how to use fadeout

#https://github.com/Zulko/moviepy/issues/2138

from moviepy.editor import *

(video_width, video_height) = (1080,1920)

clip1 = TextClip("Hello",fontsize=100,size=(video_width, video_height),bg_color="blue",color="white").set_duration(1)
clip2 = TextClip("There",fontsize=100,size=(video_width, video_height),bg_color="blue",color="white").set_duration(1)

magic_time = 0.5

concat_clip = CompositeVideoClip([clip1,clip2.set_start(clip1.duration)])

concat_clip = concat_clip.fadeout(magic_time)

concat_clip.write_videofile("issue2138.mp4",fps=24)