[英]how to stream microphone audio from browser to S3
I want to stream the microphone audio from the web browser to AWS S3.我想 stream 麦克风音频从 web 浏览器到 AWS S3。 Got it working
成功了
this.recorder = new window.MediaRecorder(...);
this.recorder.addEventListener('dataavailable', (e) => {
this.chunks.push(e.data);
});
and then when user clicks on stop upload the chunks new Blob(this.chunks, { type: 'audio/wav' })
as multiparts to AWS S3.然后当用户单击停止将块
new Blob(this.chunks, { type: 'audio/wav' })
作为多部分上传到 AWS S3 时。
But the problem is if the recording is 2-3 hours longer then it might take exceptionally longer and user might close the browser before waiting for the recording to complete uploading.但问题是,如果录制时间长 2-3 小时,那么它可能需要特别长的时间,并且用户可能会在等待录制完成上传之前关闭浏览器。
Is there a way we can stream the web audio directly to S3 while it's going on?有没有办法在 S3 进行时将 stream web 音频直接发送到 S3?
Things I tried but can't get a working example:我尝试过但无法获得工作示例的事情:
Any help will be appreciated.任何帮助将不胜感激。
You can set the timeslice
parameter when calling start()
on the MediaRecorder
.您可以在调用
timeslice
上的MediaRecorder
start()
时设置时间片参数。 The MediaRecorder
will then emit chunks which roughly match the length of the timeslice
parameter.然后
MediaRecorder
将发出与timeslice
参数的长度大致匹配的块。
You could upload those chunks using S3's multipart upload feature as you already mentioned.正如您已经提到的,您可以使用 S3 的分段上传功能上传这些块。
Please note that you need a library like extendable-media-recorder if you want to record a WAV file since no browser supports that out of the box.请注意,如果你想录制 WAV 文件,你需要一个像extendable-media-recorder这样的库,因为没有浏览器直接支持它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.