通过RTMP / Rails录制音频 [英] Recording Audio through RTMP/Rails

查看:186
本文介绍了通过RTMP / Rails录制音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个rails / flex应用程序,需要录制音频,然后存储在我们的亚马逊S3帐户。我发现使用某种形式的RTMP服务器通过闪存录制音频没有其他选择,但是我们的主机环境不允许我们安装FMS,Red5等任何东西。



是否有任何现有的Ruby / Rails的RTMP解决方案,将允许录音?如果没有,Rails是否可以至少拦截RTMP流,然后我可以希望引用red5的源代码或者解析数据的东西(我知道,远射)?

另一个我能想到的方法是在另一台主机上托管一个red5服务器,一旦保存/上传完成,就与我们的Rails应用程序进行通信,这不是首选。


解决方案

我能够得到这个工作



1)Flash Player 10.1可以获取麦克风的ByteArray 2)我捕获了这个ByteArray,使用了Adobe的WavWriter类(从麦克风教程他们放在一起)以适当的WAV格式创建一个新的ByteArray


$ b $ 3通过RubyAMF发送给Rails

< 4)沿用

  wav_data = ruby​​amf_params [0] [:wav_data] 

f = File.new('c:/hello.wav')
f<< wav_data.pack('c'* wav_data.length)
f.close

已经得到这个wav的数据,它不会太远,将其转换成一个MP3,哇


I am in the process of building a rails/flex application which requires audio to be recorded and then stored in our amazon s3 account. I have found no alternative to using some form of RTMP server for recording audio through flash, but our hosting environment will not allow us to install anything like FMS, Red5, etc.

Is there any existing Ruby/Rails RTMP solution that will allow audio recording? If not, is it possible for Rails to at least intercept the RTMP stream and then I can hope to reference red5's source or something for parsing the data (long shot, I know)?

The other alternative I can think of is hosting a red5 server on another host and communicating with our rails app once the saving/uploading is done, which is not preferred.

Am I going to have any luck here?

解决方案

I was able to get this to work

1) Flash Player 10.1 can get the microphone's ByteArray

2) I captured this ByteArray, used Adobe's WavWriter class (from a microphone tutorial they put together) to create a new ByteArray in proper wav format

3) Sent this over to rails through RubyAMF

4) Used something along the lines of

wav_data = rubyamf_params[0][:wav_data]

f = File.new('c:/hello.wav')
f << wav_data.pack('c'*wav_data.length)
f.close

Once I've got this wav data it won't be too far of a stretch to convert it to an mp3, woo

这篇关于通过RTMP / Rails录制音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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