Jump to content

Record video from PIXI canvas with CCapture.js


Recommended Posts

Hey guys!

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:


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;

});

 

Also I created some example and you can see it stops at the beginning too: 

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

 

I would be grateful for any help!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...