function record()
    {
        console.log('VideoRecorder : record()');

        var ctx = canvas.getContext('2d');
        var CANVAS_HEIGHT = canvas.height;
        var CANVAS_WIDTH = canvas.width;

        frames = []; // clear existing frames;
        startTime = Date.now();

        /*
        function drawVideoFrame(time) 
        {
            // Draw video onto canvas, and read back canvas as webp
            ctx.drawImage(video, 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
            frames.push(canvas.toDataURL('image/webp', 1)); // image/jpeg is way faster :(
            console.log('push frame');

            rafId = requestAnimationFrame(drawVideoFrame);
        };
        rafId = requestAnimationFrame(drawVideoFrame);
        //*/
        
        // Frame redraw function
        rafId = setInterval(function() 
        {
            // Draw video onto canvas, and read back canvas as webp
            //  Unfortunately, image/jpeg is way faster :(
            ctx.drawImage(video, 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
            frames.push(canvas.toDataURL('image/webp', RECORDING_QUALITY));

        }, TIME_FRAME_DELAY);
        //*/
    }
// Begin actual recording of video frames
Begin actual recording of video frames
Begin actual recording of video frames
function record()
    {
        console.log('VideoRecorder : record()');
        var ctx = canvas.getContext('2d');
        var CANVAS_HEIGHT = canvas.height;
        var CANVAS_WIDTH = canvas.width;
        frames = []; 
        startTime = Date.now();
        rafId = setInterval(function() 
        {
            ctx.drawImage(video, 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
            frames.push(canvas.toDataURL('image/webp', RECORDING_QUALITY));
        }, TIME_FRAME_DELAY);
    }
function record ( ) { console . log ( 'VideoRecorder : record()' ) ; var ctx = canvas . getContext ( '2d' ) ; var CANVAS_HEIGHT = canvas . height ; var CANVAS_WIDTH = canvas . width ; frames = [ ] ; startTime = Date . now ( ) ; rafId = setInterval ( function ( ) { ctx . drawImage ( video , 0 , 0 , CANVAS_WIDTH , CANVAS_HEIGHT ) ; frames . push ( canvas . toDataURL ( 'image/webp' , RECORDING_QUALITY ) ) ; } , TIME_FRAME_DELAY ) ; }
Begin actual recording of video frames
Begin actual recording of video frames
// clear existing frames; /*
        function drawVideoFrame(time) 
        {
            // Draw video onto canvas, and read back canvas as webp
            ctx.drawImage(video, 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
            frames.push(canvas.toDataURL('image/webp', 1)); // image/jpeg is way faster :(
            console.log('push frame');

            rafId = requestAnimationFrame(drawVideoFrame);
        };
        rafId = requestAnimationFrame(drawVideoFrame);
        //*/ // Frame redraw function // Draw video onto canvas, and read back canvas as webp //  Unfortunately, image/jpeg is way faster :( //*/