Skip to content

Instantly share code, notes, and snippets.

@bit2shift
Last active May 1, 2019 03:32
Show Gist options
  • Save bit2shift/09c93ee0f642ee417005a70275cdd34f to your computer and use it in GitHub Desktop.
Save bit2shift/09c93ee0f642ee417005a70275cdd34f to your computer and use it in GitHub Desktop.
Captures angeriness as WebM/VP9 video (updated canvas size for new reacts)
//beforehand, hover the reaction's pop-up and keep it in focus while recording
function make_canvas_recorder(canvas, filename)
{
var chunks;
var recorder = new MediaRecorder(canvas.captureStream(), {'mimeType' : 'video/webm;codecs=vp9', 'videoBitsPerSecond' : 1e10});
recorder.ondataavailable = function(e){chunks.push(e.data);};
recorder.onstart = function(e){chunks = [];};
recorder.onstop = function(e)
{
var a = document.createElement('a');
a.href = URL.createObjectURL(new Blob(chunks, {'type' : 'video/webm'}));
a.download = filename;
a.click();
};
return recorder;
}
cnv = document.querySelector('[data-reaction="8"] canvas');
cnv.width = cnv.height = 180;
cnv.removeAttribute('style');
rec = make_canvas_recorder(cnv, 'angery.webm');
rec.start();
setTimeout(function(){rec.stop();}, 10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment