[Vuejs]-Smooth 60 fps video from konva canvas animation using ccapturejs

1👍

Use this code to pause the video and take screenshots. You can than use Whammy to generate a webm and convert it to whatever file format you like with ffmpeg

  generateVideo(){
            const vid = new Whammy.fromImageArray(this.captures, 30);
            vid.name = "project_id_238.webm";
            vid.lastModifiedDate = new Date();

            this.file = URL.createObjectURL(vid);
    },
    async pauseAll(){
       this.pauseVideo();
      if(this.animations.length){
       this.pauseLotties()
      }
            this.captures.push(this.canvas.toDataURL('image/webp'));
            if(!this.ended){
              setTimeout(()=>{
                this.pauseAll();
              }, 500);
            } 
    },
    async pauseVideo(){
      console.log("curretTime",this.video.currentTime);
      console.log("duration", this.video.duration);
        this.video.pause();
       const oneFrame = 1/30;
      this.video.currentTime += oneFrame;
    },
    async pauseLotties(){
      lottie.freeze();
        for(let i =0; i<this.animations.length; i++){
          let step =0;
          let animation = this.animations[i].lottie;
          if(animation.currentFrame<=animation.totalFrames){
            step = animation.currentFrame + animation.totalFrames/30;
          }
          lottie.goToAndStop(step, true, animation.name); 
        }
      },

Leave a comment