Coder Social home page Coder Social logo

Problems with complex mask about moviepy HOT 4 CLOSED

zulko avatar zulko commented on May 21, 2024
Problems with complex mask

from moviepy.

Comments (4)

Zulko avatar Zulko commented on May 21, 2024

Thanks for the interesting issue. This is indeed puzzling, for the moment I can't understand if it's a bug (= MoviePy really not working as expected), a problem in your code, or maybe a problem with the gifs or how they are read. Have you used masks for other purposes yet ? Have you had any issue ? I have made complex things with masks before and never had any issue. I'll have a better look into it when I have time.

PS: is this for reddit/perfectloops or something like this ;) ?

from moviepy.

Zulko avatar Zulko commented on May 21, 2024

I think I can confirm that your problem is a due to the combined facts that (1) the GIFs are somehow corrupted (some frames cannot be read by MoviePy) and (2) you are making copies of clips which all refer to the same video reader.

I'll try to explain: a videofileclip in moviepy has a "reader" which is like a pipe to the data on the hard drive. When you make a copy of the clip (for instance with clip2 = clip.set_start(t0) ) the reader is not copied (because it takes lots of place in the memory), the reader will be shared by clip and its derivative clip2. Now, if clip asks the reader for a frame at some time t and the reader cannot read it (because the file is somehow corrupted like in your example), the reader will instead give the last frame read. Normally this is the frame just before t and the reading error is barely noticeable (the video staggers a little as it has two identical frames in a row). But if two clips are using the same reader, the last frame read can also be a frame anywhere else in the video.

This is what happens in your example: the reader can't read a frame and instead it gives the last frame read, which has actually been read by another clip, at a completely different time. So the clip and the masks are out of sync and strange stuff happens.

from moviepy.

Zulko avatar Zulko commented on May 21, 2024

I don't want to spoil the fun, but here is a version that works :D. It only needs the source, not the mask gif. See the result here.

https://gist.github.com/Zulko/9e65c119b9c9ad027608

from moviepy.

RealJTG avatar RealJTG commented on May 21, 2024

Thanks, I'll dig around a bit

from moviepy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.