将来自getUserMedia()的音频编码为JavaScript中的.OGG [英] Encode audio from getUserMedia() to a .OGG in JavaScript

查看:146
本文介绍了将来自getUserMedia()的音频编码为JavaScript中的.OGG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在研究这个HTML5项目,我将iOS应用程序转换为基于Web的应用程序。伴随应用程序内容创建的一部分是录音,我试图在JavaScript中复制而不使用插件;到目前为止,我已经能够从getUserMedia()录制音频,并通过Recorder.js将其转换为WAV。

So I have this HTML5 project I'm working on, where I'm converting an iOS app to a web-based one. Accompanying part of the content creation of the app is an audio recording, which I'm trying to replicate in JavaScript without the use of plugins; so far, I've been able to record audio from getUserMedia(), and turn it into a WAV thanks to Recorder.js.

现在,我是有点失落。我目前有两个单独的视图,一个用于录制内容,一个用于播放,但我不知道如何将录制的音频从Recorder.js导入到我的JSON有效载荷中进行播放(我想避免强制服务器)上传或客户端下载)。

Now, however, I'm a bit lost. I currently have two separate views, one for recording content and one for playing it back, but I don't know how to get the audio exported form Recorder.js into my JSON payload for playback (I'd like to avoid forcing a server upload or client download).

所以我想我的具体问题是,我如何获取Recorder制作的blob对象(我几乎一无所知) .js并将其转换为原始数据,或以某种方式通过JSON发送文件?

更新:我已经决定尝试使用speex.js工具( https://github.com/jpemartins/speex.js )进行编码一个.OGG(远小于.WAV)。但是,我不确定如何使用它;演示页面似乎对我不起作用,并试图调用Speex对象的 .encode()函数似乎实际上并不对数据进行编码,I只在对象字段中获得零。有没有人知道我可以学习如何使用这种工具的任何资源?

UPDATE: I've decided to try and use the speex.js tool (https://github.com/jpemartins/speex.js) to encode a .OGG (much smaller than a .WAV). However, I'm not really sure how to use it; the demo page didn't seem to work for me, and trying to call the .encode() function of a Speex object doesn't seem to actually encode the data, I only get zeros in the object fields. Does anyone know of any resources where I can learn how to use this type of tool?

推荐答案

有一个库(MIT许可) )应该工作,我相信我已经看到这个确切的库用于不久前在网站上的getUserMedia音频流中保存ogg文件。我隐约记得图书馆的名字,但我认为这是一个:

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

GitHub上的整个项目:
https://github.com/streamproc/MediaStreamRecorder/

The whole project on GitHub: https://github.com/streamproc/MediaStreamRecorder/

由于看起来很难实现这一点,所以至少值得一看理解这些概念 - 但我会说它是相当先进的javascript我们在这里处理......

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...

这篇关于将来自getUserMedia()的音频编码为JavaScript中的.OGG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆