Advertisement
IWBH_01

javascript video capture tinkering

Mar 20th, 2022
1,954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var startR=document.createElement("button"),stopR=startR.cloneNode();
  2.  
  3. document.body.appendChild(startR);
  4. document.body.appendChild(stopR);
  5. startR.innerText="start capture";
  6. stopR.innerText="stop capture";
  7.  
  8.  
  9. self.auc=new AudioContext();
  10. var mes=auc.createMediaElementSource(document.getElementsByTagName("video")[0]);
  11. self.audio_merge=auc.createMediaStreamDestination();
  12. mes.connect(audio_merge);
  13.  
  14. startR.onclick=function(){
  15. navigator.mediaDevices.getDisplayMedia({ video: true }).then(function(disp){
  16.  
  17.  
  18.  
  19. var mediaRecorder1 = new MediaRecorder(disp,{"mimeType":"video/webm"/* , "audioBitsPerSecond":128*1024 */ }),
  20.  mediaRecorder2 = new MediaRecorder(audio_merge.stream,{"mimeType":"audio/ogg"/* , "audioBitsPerSecond":128*1024 */ });
  21.  
  22. self.Rchunks = []; self.Rchunks2=[];
  23. mediaRecorder1.ondataavailable = function(e) {
  24.   Rchunks.push(e.data);
  25. },
  26. mediaRecorder2.ondataavailable = function(e) {
  27.   Rchunks2.push(e.data);
  28. };
  29.  
  30. setTimeout(function(){
  31.   mediaRecorder1.start();
  32.   mediaRecorder2.start();
  33. },1000);
  34.  
  35.  
  36. stopR.onclick=function(){
  37. mediaRecorder1.stop();mediaRecorder2.stop();
  38. };
  39.  
  40. });
  41.  
  42. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement