Jump to content

Flipping video image horizontally from user camera stream


tjs
 Share

Recommended Posts

I'm rendering the stream from the user's camera onto the canvas by this method:

this._videoTexture = PIXI.Texture.fromVideo(this._videoDomElement);

this._videoSprite = new PIXI.Sprite(this._videoTexture);

I need to flip the image produced horizontally though and I was wondering the best way to do it.   

Link to comment
Share on other sites

Hey thanks for this, it works perfectly. 

I guess if I just set the scale.x = -1 without the other changes then it would be rendering outside the bounds of the sprite.

I wonder how intensive the calculations are to render and flip the video are every frame or whether it would be more optimised to have the canvas transparent and play the video in a dom web element underneath instead.

Link to comment
Share on other sites

Don't do it every frame. Do it once, when the video starts playing.

All objects coordinate systems are being multiplied by their matrix either way, regardless of their transforms.

It's the same amount of calculation for whether you transform it or not.

Edited by ZackMercury
Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...