in flex, is it possible to embed speex files?

不羁的心 提交于 2019-12-05 11:04:57

问题


Flash 10 supposedly has support for the Speex audio format. I'd like to embed some Speex files in my SWF:

[Embed(source='assets/test.spx',mimeType='audio/x-speex')]
private static const SpeexSound:Class;

However, I get the error:

no transcoder registered for mimeType 'audio/x-speex'

Any ideas?


回答1:


Speex is not a real transport format -- it has no framing built into the protocol, so it is typically wrapped in an OGG stream (whose API is unfortunately more complicated than the Speex API itself, but I digress...) So "audio/x-speex" really means "Speex in OGG".

I haven't seen anywhere that Flash supports OGG -- so those files you get from speexenc aren't going to work :(

Reportedly Flash encodes/decodes Speex in FLV format (according to this page: http://jira.red5.org/confluence/display/codecs/Speex+Codec). I haven't tried this because I want to target Flash 9 (maybe ffmpeg would encode correctly with some fiddling) but let me know if you get anywhere with this.




回答2:


I've been researching this some more. Here are the options:

  1. Embed an ogg speex file and use an Alchemy-compiled libOgg and libSpeex to decode it. The decoded bytes can be fed into Flash via SampleDataEvent.SAMPLE_DATA. Its painfully ironic that Alchemy has to be used, when we know that libSpeex lives in the Flash Player somewhere.
  2. You can't embed FLVs, but you can embed SWFs, so convert a Speex FLV into a Speex SWF. The conversion can be done with ffmpeg like this:

    $ ffmpeg -i test-with-speex.flv -vn test.swf
    

    However, that will unfortunately auto-convert the audio into MP3 inside the SWF. You should be able to preserve the codec like this

    $ ffmpeg -i test-with-speex.flv -vn -acodec libspeex test.swf
    

    but ffmpeg doesn't currently support non-MP3 SWFs. Grr. Perhaps there's other conversion tools that will do it?




回答3:


On the server-side, you can use this tricked-out ffmpeg project:

http://code.google.com/p/xuggle-ffmpeg/

And encode your audio something like this:

ffmpeg -i test.wav -acodec libspeex -f flv -y speex.flv


来源:https://stackoverflow.com/questions/1148028/in-flex-is-it-possible-to-embed-speex-files

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