Adobe flash : Playing Speex Audio from a file

泪湿孤枕 提交于 2019-12-22 14:08:31

问题


I have tried really hard to find an example showing how to play speex encoded audio in flash. I tried the following code -

var connect_nc:NetConnection = new NetConnection();
connect_nc.connect(null);
var stream_ns:NetStream = new NetStream(connect_nc);
stream_ns.play("RE-Sample.m4a");

avaible at -

http://www.adobe.com/devnet/flashplayer/articles/hd_video_flash_player _03.html

I tested the above code with .flv videos and AAC encoded audio files and it works just fine. But when I try stream_ns.play("sample.spx") I get a stream not found exception.

Am I using the wrong container (.spx) for speex audio. Is playing speex audio from a file supported? please help!

(It would be great if you can provide an example.)


回答1:


ArtBIT seems to be correct from my tests as well. SPX is only playable as the audio codec in a FLV container. You have a few options:

  1. wrap your SPX files ahead of time with a FLV container by reencoding them.
  2. do a "live" transcode using FMS or Red/Xuggle (http://www.pubbs.net/200906/osflash/18579-red5-streaming-speex-audio.html)
  3. load the SPX as a bytearray, then wrap it with an FLV using a library like this: http://www.zeropointnine.com/blog/simpleflvwriteras-as3-class-to-create-flvs/

Hope this helps.




回答2:


You will have to put it in the flv container, none of the flash media servers will allow it in any other form (unless its a live broadcast). You can convert your files with newer versions of ffmpeg like so:
ffmpeg -i RE-Sample.m4a -y -vn -acodec libspeex -ac 1 -ar 16000 -f flv RE-Sample.flv




回答3:


This sounds like a job for Alchemy. With Alchemy you could convert a Speex decoder from C to AS3. Here is a link to Adobe Labs where they have an example of converting an OggVorbis decoder from C to AS3: http://labs.adobe.com/wiki/index.php/Alchemy:Libraries




回答4:


According to http://osflash.org/flv#codecs1 flv is the only container that supports speex codec.

Try with flv?



来源:https://stackoverflow.com/questions/3414777/adobe-flash-playing-speex-audio-from-a-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!