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

CompositeVideoClip([xxx]).rotate(90) ValueError: axes don't match array #1042

Closed
clotyxf opened this issue Nov 28, 2019 · 6 comments
Closed
Labels
bug Issues that report (apparent) bugs.

Comments

@clotyxf
Copy link

clotyxf commented Nov 28, 2019

Expected Behavior

Specifications

  • Python Version: 3.6.3
  • Moviepy Version: 1.0.1
  • Platform Name: Centos
  • Platform Version: 7.2

Actual Behavior

size = (640, 320)
fps = 24
bg_clip = mpy.ImageClip(img=image, fromalpha=True)
bg_clip = bg_clip.resize(size).set_duration(d).set_fps(fps )
bg_clip = mpy.CompositeVideoClip([bg_clip])
bg_clip.rotate(90)

ValueError: axes don't match array

change the angle to 89.99, is worked.
@clotyxf clotyxf closed this as completed Dec 3, 2019
@rriokwok
Copy link

bg_clip.rotate(90, expand=False) would give what you want.

@misland
Copy link

misland commented Mar 19, 2020

        if (a==90) and expand:
            return np.transpose(im, axes=transpo)[::-1]
        elif (a==-90) and expand:
            return np.transpose(im, axes=transpo)[:,::-1]
        elif (a in [180, -180]) and expand:
            return im[::-1,::-1]

code in moviepy->video->fx->rotate.py,line 58~63,that's why 89.99 worked.
@clotyxf could you reopen this issue?89.99 shouldn't be the workaround
@tburrows13 hi,could you explain why,many thanks :)

@misland
Copy link

misland commented Mar 19, 2020

bg_clip.rotate(90, expand=False) would give what you want.

image will lose part of it when expand is set to true,so this should be the workaround

@misland
Copy link

misland commented Mar 19, 2020

I just copy the code in line 69 to line 59

if (a==90) and expand:
            return pil_rotater(im, a, resample=resample, expand=expand)
            # return np.transpose(im, axes=transpo)[::-1]

then it works fine,I don't know why we do this specialized processing when the angle is set to 90
@Earney

@tburrows13
Copy link
Collaborator

Hi, it definitely seems like it is a bug to do with RGBA images. See #781 and #990 for the same error message.

The reason why angles 90, -90, 180 and -180 are special is because they can be easily done by directly transposing the image array using numpy. More complicated rotations require pillow, which is an optional library, and may perform the rotations slower. However, if this bug cannot properly be fixed, then it might be worth using the pillow method as a fall back.

@tburrows13 tburrows13 reopened this Apr 6, 2020
@tburrows13 tburrows13 added the bug Issues that report (apparent) bugs. label May 14, 2020
@nicoeps nicoeps mentioned this issue Oct 7, 2020
5 tasks
@tburrows13
Copy link
Collaborator

Fixed in #1335

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that report (apparent) bugs.
Projects
None yet
Development

No branches or pull requests

4 participants