phoboslab / jsmpeg

MPEG1 Video Decoder in JavaScript
MIT License
6.3k stars 1.43k forks source link

how to use jsmpeg.player output in object detection code. #416

Open sazzad15-1779 opened 11 months ago

sazzad15-1779 commented 11 months ago

can anyone help me to use jsmpeg streaming in object detection function. const player = new JSMpeg.Player("ws://localhost:9999", { canvas: canvas, autoplay: true, loop: true, decodeFirstFrame: true, }); how to get video data from this streaming?

phoboslab commented 11 months ago

What is "video data"? Raw pixels?

Depending on the disableGl option, you can get pixel data from

If performance is important and black & white is enough, you may hook into the renderer interface and forward the luma plane (y) to your object detection.

If you need color information, you may also hook into the Canvas2D renderer here and forward the Uint8TypedArray with the RGBA data this.imageData.data without going through the Canvas API first. This may be slower than doing the color space conversion in WebGL and using readPixels() though.