Recordy icon indicating copy to clipboard operation
Recordy copied to clipboard

recording mic and speaker --> single wav file

Open jschimmoeller opened this issue 9 years ago • 5 comments

I have a video tag and can record the mic input but how do I also record the speaker output at the same time?

jschimmoeller avatar Nov 11 '16 22:11 jschimmoeller

So would you like to record the output of the video tag?

If you want to record any other AudioNode or Chnl, just connect that to your recordy instance as you would connect a normal AudioNode.

scriptify avatar Nov 12 '16 10:11 scriptify

yes i am trying to record from a video tag

here is the code i am using:

` var audioCtx = new AudioContext(); var mediaSource = audioCtx.createMediaElementSource(document.getElementsByTagName('video')[0]); var r = new Recordy(audioCtx);

r.getInput() .then(function(val){ r.startRecording();

// only record 10 seconds
setTimeout(function() {
  r.stopRecording(true)
    .then(function(audio) {
      // play it
      console.log('about to play');
      setTimeout(function(){
        console.log('Playing ')
        audio.play();
      }, 10000)

    });
}, 10000);

}); `

jschimmoeller avatar Nov 13 '16 14:11 jschimmoeller

You need to connect the MediaStreamSource-object to the Recordy instance. Recordy doesn't record everything which would be outputted to the speakers. There's just an option to output the input to Recordy to the speakers, but that's another use case.

It should work if you do the following:

...
// Connect the mediaSource as an input to Recordy
mediaSource.connect(r);
...

scriptify avatar Nov 13 '16 14:11 scriptify

still no success. I have saved the recording and play it back but all that is in the recording is a click. It is 10seconds long and 1.8mb in size. The video tag is hooked up to a webrtc playing a recording.

the video tag looks like this; hard to capture since it is dynamically created and removed.

<video id="web-1479050168368" autoplay hidden src="blob:http://localhost:8080/2a0176fe-1632-40c5-838f-e78e11d307f6"></video>

here is the code I am using:

` var audioCtx = new AudioContext(); // dynamic video tag so i will find all and just use last ... only should be one var videoTags = document.getElementsByTagName('video'); var mediaSource = audioCtx.createMediaElementSource(videoTags[videoTags.length-1]); console.log('vtag using: ', videoTags[videoTags.length - 1]); var r = new Recordy(audioCtx); var x = mediaSource.connect(r);

r.startRecording();

// only record 10 seconds setTimeout(function() { r.stopRecording(true) .then(function(audio) { console.log(' stopped ---- ') setTimeout(function(){ console.log('playing NOW ') audio.play() audioCtx.close(); }, 5000) }); }, 10000); `

Thanks for all your help by the way.

jschimmoeller avatar Nov 13 '16 15:11 jschimmoeller

If you output the Recordy input directly to the speakers, do you hear something?

So if you do r.toSpeaker(1) you should hear something.

You're welcome! I am always trying to improve my libraries and detecting possible bugs is a good thing.

scriptify avatar Nov 13 '16 16:11 scriptify