Giter VIP home page Giter VIP logo

Comments (3)

drabinowitz avatar drabinowitz commented on June 1, 2024 1

ah my apologies for the delay I think this would work for me thanks a lot!

from whammy.

Nikaoto avatar Nikaoto commented on June 1, 2024

Had the same problem when compiling complex videos (with globalOpacity and lots of frames).

The easiest workaround I've found is to just add an empty frame to the video, that way, the last part gets cut instead of the actual content you want to put in the video.

So in this case, it would be:

var video = new Whammy.Video;
video.duration = 15000;
video.quality = 1;
//assuming here that we have an image from a canvas to use:
video.add(context);


// Fill the canvas with a black rectangle
context.fillStyle = "#000000"
context.fillRect(0, 0, context.canvas.width, context.canvas.height)
video.add(context, 1) // Doesn't matter what duration you put here, still gets cut to the first frame


video.compile();

EDIT:
The solution I proposed has one flaw, it leaves a black screen as the last frame.
Also, using context.clearRect does not work. You have to have image data on the canvas for whammy to add the frame to the video. The next best performant thing would probably be just doing context.fillRect(0, 0, 1, 1) but that doesn't work either.
You could experiment to find out what would be the smallest rectangle you could draw so you could improve performance, but it's only one frame anyway.

from whammy.

Nikaoto avatar Nikaoto commented on June 1, 2024

@drabinowitz Please indicate if my solution helped you so the owner can close the issue 🙂

from whammy.

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.