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

concatenate ImageClip #285

Closed
vparitskiy opened this issue Apr 20, 2016 · 2 comments
Closed

concatenate ImageClip #285

vparitskiy opened this issue Apr 20, 2016 · 2 comments
Labels
bug Issues that report (apparent) bugs.

Comments

@vparitskiy
Copy link
Contributor

vparitskiy commented Apr 20, 2016

Create several ImageClips:

clip_1 = ImageClip(imread('path_to_img.png'), duration=10)
clip_2 = ImageClip(imread('path_to_img.png'), duration=10)
clip_3 = ImageClip(imread('path_to_img.png'), duration=10)

merged_clip = concatenate_videoclips([clip_1, clip_2, clip_3])

It will fail with error:

Traceback (most recent call last):
 File "XXXXXX/tasks.py", line 93, in merge_video
    clip = concatenate_videoclips(clips)
  File "XXXXXX/lib/moviepy/video/compositing/concatenate.py", line 95, in concatenate_videoclips
    result.mask = concatenate_videoclips(masks, method="chain", ismask=True)
  File "XXXXXX/lib/moviepy/video/compositing/concatenate.py", line 72, in concatenate_videoclips
    tt = np.cumsum([0] + [c.duration for c in clips])
  File "XXXXXX/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 2114, in cumsum
    return _wrapit(a, 'cumsum', axis, dtype, out)
  File "XXXXXX/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 48, in _wrapit
    result = getattr(asarray(obj), method)(*args, **kwds)
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

I discovered that while creating ImageClip instance with transparent=True, it sets self.mask to another ImageClip, but without duration.

And in concatenate_videoclips function it checks if any clip has mask and calculate duration. But duration is None, that's why TypeError.

Maybe, it should set mask.duration to clip.duration?

@keikoro keikoro added the bug Issues that report (apparent) bugs. label Feb 18, 2017
@ghost
Copy link

ghost commented Feb 21, 2017

pull request #435 addresses this issue. I do bring up a question if there is a better way of setting the duration for the mask when we use ImageClip. Hopefully one of the more experienced developers will take a look for me.

@ghost ghost mentioned this issue Feb 27, 2017
@ghost
Copy link

ghost commented Mar 7, 2017

This has been fixed in the repo. @vparitskiy, let us know if you run into other issues.

This issue was closed.
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

2 participants