-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zoom-In Effect for moviepy #1402
Comments
Possible explanation for wobbling (in your solution)The wobbling effect might be caused by the use of
It's likely a combination of both, depending on the circumstance. Given the out-of-phase nature of the hypothesized causes, I think wobbling occurs whenever the number of frames that the effect lasts ( Possible reason your solution wobbles less
By evening the width and height, you're essentially forcing the ratio between the width and height to fluctuate less. |
Looking at the various Proposed solutionAlways maintain the ratio of width-to-height by first calculating the new width, then calculating the height based on the width. So replace new_size = [
math.ceil(img.size[0] * (1 + (zoom_ratio * t))),
math.ceil(img.size[1] * (1 + (zoom_ratio * t)))
]
# The new dimensions must be even.
new_size[0] = new_size[0] + (new_size[0] % 2)
new_size[1] = new_size[1] + (new_size[1] % 2) with something like w, h = img.size
new_w = w * (1 + (zoom_ratio * t))
new_h = new_w * (h / w)
# Determine the height based on the new width to maintain the aspect ratio.
new_size = (new_w, new_h) |
Problem: Solution: Only increase the width & height with the aspect ratio (or multiple of it). An ideal aspect ratio would be a 1:1 ratio and place your content in it masking the space left. I'm about to try out the theory. If anybody's still interested in an example code let me know |
@kalloszsolty I'm interested!! :) |
Use this function to create a perfectly square image with even width and height:
Then just use a lambda function to increase the width and height with the same integer:
|
At the end, I ended up generating separate videos of zooming with command line ffmpeg
increase the zoom_smooth parameter for example to 10 to get a smoother zoom (it will also take you more time/resources) |
For anyone wanting a periodic zoom-in and out effect. I've used a sin wave to replicate that.
|
I am getting |
Maybe this will help. |
Just curious which is the solution? Because the output video still seems to wobble... |
the input is 1 video, what to do! |
Worked! |
Thanks! This is a command version that also works based on this. ffmpeg -y -loop 1 -t 17 -i /PATH_TO_IMAGE/image-0.png -vf "scale=iw5:ih5,zoompan=z='min(zoom+0.0015,1.5)':x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)':d=510,scale=1344:768,trim=duration=17,fps=30" -c:v prores /PATH_TO_OUTPUT/output.mov |
'ImageClip' object has no attribute 'fl' im using the updated version of moviepy |
@steinathan thanks for your comment, I'll see what changes have been made and update the code. |
Thanks @mowshon I was able to update it and it works perfectly the old “.fl” is now “transform” and it works |
I am trying to create a video from slides. Each slide has a zoom-in effect. All the code examples for creating the zoom-in effect gave poor results if the zoom speed is very slow. The side effect was a slight twitching.
Below I will provide examples that the documentation offers and the function that I offer.
The problem I faced too: #183
Example from documentation
https://zulko.github.io/moviepy/ref/videofx/moviepy.video.fx.all.resize.html
Result: https://youtu.be/qlU_4hVFm6I
My function
Slideshow example: https://gist.github.com/mowshon/2a0664fab0ae799734594a5e91e518d5
Result: https://youtu.be/U-A54E00sC8
In my example, there is also a slight wobble, but not as obvious as in the first example. Below is a link to a video where you can compare both options.
Comparation video: https://www.youtube.com/watch?v=UPyYdrwWE14
I would be glad to get advice on improving the code.
The text was updated successfully, but these errors were encountered: