tags:

views:

608

answers:

2

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  A: 

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.

sehugg
The problem is that it doesn't seem that we can embed FLV files. :/
paleozogt
A: 

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?

paleozogt