I'm trying to use slide in and out transitions between videoclips with no luck I was only available to make it work using crossfadein like this:
from moviepy.editor import VideoFileClip, concatenate_videoclips, vfx, afx, transfx, concatenate,
CompositeVideoClip
output = "out.mp4"
delay = 1
clip1 = VideoFileClip("174_3.mp4")
clip2 = VideoFileClip("174_4.mp4")
clip3 = VideoFileClip("174_5.mp4")
clip4 = VideoFileClip("174_6.mp4")
final = concatenate([clip1,
clip2.crossfadein(delay),
clip3.crossfadein(delay),
clip4.crossfadein(delay)],
padding=-delay, method="compose")
final.write_videofile(output)
But when I use the example on https://github.com/Zulko/moviepy/blob/3d86a2c4cba6769528112765d964eaec273d7636/moviepy/video/compositing/transitions.py
from moviepy.editor import VideoFileClip, concatenate_videoclips, vfx, afx, transfx, concatenate,
CompositeVideoClip
output = "out.mp4"
clip1 = VideoFileClip("174_3.mp4")
clip2 = VideoFileClip("174_4.mp4")
clip3 = VideoFileClip("174_5.mp4")
clip4 = VideoFileClip("174_6.mp4")
clips = [clip1, clip2, clip3, clip4];
CompositeVideoClip(clips)
slided_clips = [clip.fx( transfx.slide_out, 1, 'bottom') for clip in clips]
final_clip = concatenate( slided_clips, padding=-1)
final_clip.write_videofile(output)
This result is videos concatenated but not transition at all, please let me know what I'm doing wrong
This would indeed be very helpful. Is there really nobody who knows how to execute this functionality?
The docs say nothing about this, and the source is, ehrm, not too helpful in this instance ;-)
I'm copying my answer from https://stackoverflow.com/questions/46517510/moviepy-slidein-and-slideout-transitions/49617291#49617291:
Remember that most functions in moviepy do not modify the object, but return a modified shallow copy of the object - so the line CompositeVideoclip(clips) does not do anything.
Instead, you want to do:
slided_clips = [CompositeVideoClip([clip.fx( transfx.slide_out, 1, 'bottom')]) for clip in clips]
The reason why slide_out has to be in CompositeVideoClip is because it changes the position of the clip, so it needs to be in a "frame" to leave part of the screen blank. It's the same reason why set_position works only with CompositeVideoClip.
I think this issue can be closed. I'll create a PR to change the examples.
@knezi I don't know if the PR you mentioned ever happened, but I am going to close this issue as per your above msg.
@keikoro Yep, see the second commit: https://github.com/Zulko/moviepy/pull/795
It's been waiting for merge for half a year. Can you take a look at it?
Most helpful comment
I'm copying my answer from https://stackoverflow.com/questions/46517510/moviepy-slidein-and-slideout-transitions/49617291#49617291:
Remember that most functions in moviepy do not modify the object, but return a modified shallow copy of the object - so the line CompositeVideoclip(clips) does not do anything.
Instead, you want to do:
The reason why slide_out has to be in CompositeVideoClip is because it changes the position of the clip, so it needs to be in a "frame" to leave part of the screen blank. It's the same reason why set_position works only with CompositeVideoClip.
I think this issue can be closed. I'll create a PR to change the examples.