Comments (6)
This is how I rounded the corners of my stream
function roundedImage(ctx, x, y, width, height, radius) {
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
ctx.lineTo(x + width, y + height - radius);
ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
ctx.lineTo(x + radius, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
}
merger.addStream(cameraStream, {
draw: (ctx, frame, done) => {
const x = 20;
const y = merger.height - 180;
const width = 100;
const height = 150;
ctx.save();
roundedImage(ctx, x, y, width, height, 10);
ctx.strokeStyle = "#fff";
ctx.stroke();
ctx.clip();
ctx.drawImage(frame, x, y, width, height);
ctx.restore();
done();
},
x: 20,
y: merger.height - 180,
width: 100,
height: 150,
mute: false,
});
from video-stream-merger.
There seem to be option to override draw method for each stream passed, that may work?
https://github.com/t-mullen/video-stream-merger#custom-draw-function
from video-stream-merger.
@Iulian33 Did you try to Google: "canvas image rounded corners"
from video-stream-merger.
@hthetiot we have access to method getCanvasContext() to get merged canvas already, but we do not have an option to get canvas for added stream in my case the webCamera from corner or to send on option to add corner radius to that added stream camera from corner.
from video-stream-merger.
I made it work by adding the following code to the _drawVideo() function inside the Library.
The borderRadius is a custom added attribute to the stream object which makes the corners round by the value in px.
this._ctx?.save(); this._ctx?.beginPath(); this._ctx?.moveTo(positionX + stream.borderRadius, positionY); this._ctx?.lineTo(positionX + width - stream.borderRadius, positionY); this._ctx?.quadraticCurveTo(positionX + width, positionY, positionX + width, positionY + stream.borderRadius); this._ctx?.lineTo(positionX + width, positionY + height - stream.borderRadius); this._ctx?.quadraticCurveTo(positionX + width, positionY + height, positionX + width - stream.borderRadius, positionY + height); this._ctx?.lineTo(positionX + stream.borderRadius, positionY + height); this._ctx?.quadraticCurveTo(positionX, positionY + height, positionX, positionY + height - stream.borderRadius); this._ctx?.lineTo(positionX, positionY + stream.borderRadius); this._ctx?.quadraticCurveTo(positionX, positionY, positionX + stream.borderRadius, positionY); this._ctx?.closePath(); this._ctx?.clip(); this._ctx?.drawImage(element, positionX, positionY, width, height); this._ctx?.restore();
from video-stream-merger.
@Iulian33 you have access to individual draw stream, by providing draw option on addStream like @mustafa-toptal solution here #77 (comment)
I think we can add his solution in the documentation as an example to solve this issue and provide an example usage of custom draw.
from video-stream-merger.
Related Issues (20)
- `.webm` video merge failed
- download merger.result with nodejs HOT 1
- Can I merge in an RTMP stream, instead of WebRTC?
- Crossfade between streams HOT 1
- adding more than two media streams do not work HOT 2
- Safari 14 support. HOT 5
- use OffscreenCanvas in supported browsers HOT 2
- How to merge the audio from different video streams? HOT 1
- Need to handle merger.destroy to remove audio hack also from background HOT 1
- When trying to addStream() yPosition not working HOT 4
- use AudioEffect to use GainNode to amplify gain value
- Constructor should use Partial<ConstructorOptions >
- upgrade to 4.01 with problems HOT 3
- production status HOT 1
- Black Screen on iOS browsers HOT 4
- Example from README not working HOT 2
- index.html: Failed to execute 'connect' on 'AudioNode': cannot connect HOT 1
- Types not working (using complete types instead of partials)
- request: don't hardcode framerate
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from video-stream-merger.