RSATom / WebChimera.js

[ABANDONED] libvlc binding for Electron
GNU Lesser General Public License v2.1
661 stars 105 forks source link

How to get snapshot from wcjs player using javascript #145

Closed vihar1996 closed 3 years ago

vihar1996 commented 3 years ago

I got the uint8array but i am unable to process it to an image

boonzie commented 3 years ago

use webgl video renderer to render it into canvas

vihar1996 commented 3 years ago

i am new to this field so can you please send me code sample for this

vihar1996 commented 3 years ago

thank you so much it worked @boonzie

dbussert commented 3 years ago

can you post what you used as an example for others?

vihar1996 commented 3 years ago

I used following code snippet and it worked for me. Also add webchimera.js to your node modules

var canvas = document.getElementById("your-canvas-id");
var renderContext = require("webgl-video-renderer").setupCanvas(canvas);

var player = require("webchimera.js").createPlayer();
player.onFrameReady =
    function(frame) {
        renderContext.render(frame, frame.width, frame.height, frame.uOffset, frame.vOffset);
    }

player.play("http://archive.org/download/CartoonClassics/Krazy_Kat_-_Keeping_Up_With_Krazy.mp4");

once the player starts playing the video call canvas.toDataURL() method to get snapshot/image in base64 format