Recording video from PIXI canvas with CCapture.js not working

Viewed 152

I'm stuck with one task, maybe someone has experience to help with it.

For recording video I using CCapture.js, but when I start it everything stops with no errors.

My basic code is below.

I also created other example and you can see it stops at the beginning too:

https://codepen.io/fjtwmjzf-the-lessful/pen/zYZJwvQ

const
    videoContainer = document.getElementById('videoContainer'); 
    vw = 1280,
    vh = 720,
    videoUrl = 'assets/video/landscape.mp4';

PIXI.settings.RESOLUTION = 2;

app = new PIXI.Application({
  width: vw,
  height: vh,
  backgroundColor: bgColor,
});

const videoBg = PIXI.Texture.from(videoUrl);
const videoSprite = new PIXI.Sprite(videoBg);
const videoControler = videoSprite._texture.baseTexture.resource.source;

videoContainer.appendChild(app.view);

let capturer = new CCapture( { format: 'webm' } );

let n = 0;

app.ticker.add(() => {

    if(n == 0){
        capturer.start();
    }

    capturer.capture(app.view);

    if(videoControler.currentTime >= videoControler.duration){

        capturer.stop();

        capturer.save();

        app.ticker.destroy();

    }

    n += 1;

});

0 Answers
Related