简体   繁体   English

在一个 WebGL canvas 中渲染多个视频流

[英]Render multiple video streams in one WebGL canvas

I'd like to ask those who have used JSMPEG , how do you modify it to use only one WebGL canvas for multiple video streams?请问用过JSMPEG的人,如何修改为只使用一个WebGL canvas 用于多个视频流?

I'm doing something like this:我正在做这样的事情:

const player1 = new JSMpeg.Player(url, {canvas: canvas, disableGl: false, autoplay: true, audioBufferSize: audioBuff, videoBufferSize: videoBuff});
const player2 = new JSMpeg.Player(url, {canvas: canvas2, disableGl: false, autoplay: true, audioBufferSize: audioBuff, videoBufferSize: videoBuff});
const player3 = new JSMpeg.Player(url, {canvas: canvas3, disableGl: false, autoplay: true, audioBufferSize: audioBuff, videoBufferSize: videoBuff});
const player4 = new JSMpeg.Player(url, {canvas: canvas4, disableGl: false, autoplay: true, audioBufferSize: audioBuff, videoBufferSize: videoBuff});
const player5 = new JSMpeg.Player(url, {canvas: canvas5, disableGl: false, autoplay: true, audioBufferSize: audioBuff, videoBufferSize: videoBuff});

and so on... trying 25 players/canvases.等等...尝试 25 个玩家/画布。

For 5 players the browser can handle it, adding more crashes the browser (tested with Chrome/Firefox).对于 5 个玩家,浏览器可以处理它,添加更多的浏览器崩溃(使用 Chrome/Firefox 测试)。 I'm wondering if there's a way to just use "one big canvas" to handle the WebGL stuff and that the browser would allow it?我想知道是否有一种方法可以只使用“一个大画布”来处理 WebGL 的东西并且浏览器会允许它?

Never used that library, but since you are responsible for passing the HTMLCanvasElement, passing the same every time will make it use the same WebGL context for every instance, just like you asked for.从未使用过该库,但由于您负责传递 HTMLCanvasElement,因此每次传递相同的内容将使其对每个实例使用相同的 WebGL 上下文,就像您要求的那样。

 const canvas = document.createElement('canvas'); const gl1 = canvas.getContext('webgl'); const gl2 = canvas.getContext('webgl'); console.log( "same object:", gl1 === gl2 );

But I doubt the library will work well doing so...但我怀疑图书馆这样做会不会很好......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM