There is a library (MIT licenced) which should work, I believe I have seen this exact library being used for saving ogg files from a getUserMedia audio stream on a website not long ago. I vaguely remembered the library name, but I think this is the one:
https://github.com/streamproc/MediaStreamRecorder/blob/master/AudioStreamRecorder/MediaRecorder.js
The whole project on GitHub:
https://github.com/streamproc/MediaStreamRecorder/
Since it seems so hard to achieve this, it might at least be worth a look to understand the concepts - but I'd say it's rather advanced javascript we are dealing with here...