Skip to content
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

[Feature Request] Zoom and Rotate #166

Closed
Netherdrake opened this issue May 4, 2015 · 4 comments
Closed

[Feature Request] Zoom and Rotate #166

Netherdrake opened this issue May 4, 2015 · 4 comments

Comments

@Netherdrake
Copy link

I am wondering if the following features are planned for moviepy, or what would be the best way to implement them with the current version.

1.) Zoom
Kind of like resize, except that it would take a frame from the center (x/2, y/2) and scale it up to original resolution (zoom in)? http://zulko.github.io/moviepy/ref/videofx/moviepy.video.fx.all.resize.html#moviepy.video.fx.all.resize

2.) Rotate
The current rotate solution only flips the video by 90 degree increments. I am wondering of how would it be possible to rotate for any arbitrary amount (eg. 5 degrees).
http://zulko.github.io/moviepy/ref/videofx/moviepy.video.fx.all.rotation.html#moviepy.video.fx.all.rotation

Any tips are greatly appreaciated. Thank you for the awesome work done with the library.

@Zulko
Copy link
Owner

Zulko commented May 4, 2015

Rotating from any angle is already possible as long as you have PIL installed (see the source).

I'll add a zoom feature at some time, but for the moment what you are asking is basically crop+resize. So something like this (didn't check, I hope my math is correct):

def zoom(clip, factor):
    c = (1-1.0/factor) / 2
    x_crop = int(c * clip.w)
    y_crop = int(c * clip.h)
    return clip.crop(x_crop, y_crop, -x_crop, -y_crop).resize(clip.size)

newclip = clip.fx(zoom, factor=2)

@Netherdrake
Copy link
Author

Will the arbitrary angle rotate work with Pillow?

On Mon, May 4, 2015, at 10:15 AM, Zulko wrote:

Rotating from any angle is already possible as long as you have PIL
installed (see the source[1]).

I'll add a zoom feature at some time, but for the moment what you are
asking is basically crop+resize. So something like this (didn't check,
I hope my math is correct):

def zoom(clip, factor):
c = (1-1.0/factor) / 2 x_crop = int(c *clip.w) y_crop = int(factor *
clip.h) return clip.crop(x_crop, y_crop, -x_crop,
-y_crop).resize(clip.size)

newclip = clip.fx(zoom, factor=2)

— Reply to this email directly or view it on GitHub[2].

Links:

  1. https://github.com/Zulko/moviepy/blob/master/moviepy/video/fx/rotate.py
  2. [Feature Request] Zoom and Rotate #166 (comment)

@Zulko
Copy link
Owner

Zulko commented May 4, 2015

yes

@Netherdrake
Copy link
Author

Upgrading to git version of moviepy fixed my PIL issue.

I implemented zoom as (hope its correct):

def zoom(clip, factor):
    return clip.crop(x_center=clip.w/2 , y_center=clip.h/2, width=int(clip.w*factor), height=int(clip.h*factor)).resize(clip.size)

Because I would get ValueError: tile cannot extend outside image otherwise, and I'm too lazy to try and figure out why or how to do it with 4 corner points.

Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants