简体   繁体   English

Flash / Flex Speex音频解码,播放speex文件

[英]Flash/Flex Speex audio decode, to play a speex file

I want to play *.spx files which encoded by Speex on the Web. 我想播放由Web上的Speex编码的* .spx文件。
But I have no knowledge of Flash/Flex or any Flash Audio codec. 但我不了解Flash / Flex或任何Flash Audio编解码器。 After Google search for a whole day, I got some solutions, that is: 谷歌搜索了一整天后,我得到了一些解决方案,即:

  1. Do something wrapping Speex files with a FLV container because that the Speex is only playable as the audio codec in a FLV container. 使用FLV容器执行包装Speex文件的操作,因为Speex只能作为FLV容器中的音频编解码器播放。
    Now I can play a SPX-Audio-Only FLV file in Flex, I use netStream.play("audio-only-speex.flv") , But I donot know how to wrap a Spx file with FLV container using ActionScript. 现在我可以在Flex中播放SPX-Audio-Only FLV文件,我使用netStream.play("audio-only-speex.flv") ,但我不知道如何使用ActionScript用FLV容器包装Spx文件。
    Any example project? 任何示例项目?

  2. Decode Spx using AS. 使用AS解码Spx。
    I checked out the fllowing pages that they all decoded OGG Vorbis but no Speex :( 我检查了他们都解码了OGG Vorbis但没有Speex的flfl页面:(
    http://barelyfocused.net/blog/2008/10/03/flash-vorbis-player http://barelyfocused.net/blog/2008/10/03/flash-vorbis-player
    http://www.exswap.com/?p=132 http://www.exswap.com/?p=132
    http://mauft.com/2010/11/ogg-vorbis-in-flash http://mauft.com/2010/11/ogg-vorbis-in-flash
    Adobe also provides a AS3 OggVorbis Library which ported by Alchemy: Adobe还提供了一个由Alchemy移植的AS3 OggVorbis库:
    http://labs.adobe.com/wiki/index.php/Alchemy:Libraries http://labs.adobe.com/wiki/index.php/Alchemy:Libraries

  3. FMS: do a server streaming using FMS or Red/Xuggle. FMS:使用FMS或Red / Xuggle进行服务器流式传输。 I have never heard FMS stuffs before, as well as I'm not sure whether my virtual host can support or not... 我以前从未听说过FMS的东西,我也不确定我的虚拟主机是否可以支持...

  4. Convert every Spx files to MP3. 将每个Spx文件转换为MP3。

I think the best solution is decoding Spx in AS3, Yes, I'd like to make a Spx Flash Player. 我认为最好的解决方案是在AS3中解码Spx,是的,我想制作一个Spx Flash Player。

So, I downloaded Speex Library from speex.org, installed Adobe Alchemy. 所以,我从speex.org下载了Speex Library,安装了Adobe Alchemy。 After ./configure;make the libspeex, build libspeex/speex.c out a libspeex.swc via Alchemy. 之后./configure;make的libspeex,建立libspeex / speex.c出通过炼金术libspeex.swc。 then, I donot know how to do next. 然后,我不知道接下来该怎么做。 How can I decode the speex audio with AS3? 如何使用AS3解码speex音频?
My libspeex.swc: http://demo.0x123.com/libspeex.swc 我的libspeex.swc: http ://demo.0x123.com/libspeex.swc

In addtion , should I rewrite the libspeex using Alchemy API before build the libspeex.swc? 另外 ,在构建libspeex.swc之前,我应该使用Alchemy API重写libspeex吗?

Although I am not professional in AS, but I have a strong ability to learn. 虽然我不是AS的专业,但我有很强的学习能力。 Any advice will be greatly appreciated, Thanks very much. 任何建议将不胜感激,非常感谢。

Adobe says specifically not to rely on Alchemy yet, so there's no official way to do it on the client side (as far as I know.) It's absurd given that there is clearly a speex decoder being used. Adobe特别指出不依赖Alchemy,所以在客户端没有官方的方法(据我所知)。鉴于使用了明显的speex解码器,这是荒谬的。

Can you use Xuggle's tricked-out version of ffmpeg (http://code.google.com/p/xuggle-ffmpeg/) to embed the speex in FLVs? 你可以使用Xuggle的欺骗版ffmpeg(http://code.google.com/p/xuggle-ffmpeg/)将speex嵌入FLV吗? If you can run xuggle in batch or on the fly, then regardless of the original audio format, you can serve a speex encoded FLV, playable from netStream.play . 如果您可以批量或动态运行xuggle,那么无论原始音频格式如何,您都可以提供speex编码的FLV,可以从netStream.play播放。

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

For basic playing, you wouldn't even need a flash media server. 对于基本播放,您甚至不需要闪存介质服务器。

Now I've known that I must rewrite the speex library using alchemy API: 现在我知道我必须使用炼金术API重写speex库:
http://labs.adobe.com/wiki/index.php/Alchemy:Documentation:Developing_with_Alchemy:C_API http://labs.adobe.com/wiki/index.php/Alchemy:Documentation:Developing_with_Alchemy:C_API
http://labs.adobe.com/wiki/index.php/Alchemy:Documentation:Developing_with_Alchemy:AS3_API http://labs.adobe.com/wiki/index.php/Alchemy:Documentation:Developing_with_Alchemy:AS3_API

I've done a simple helloWorld. 我做了一个简单的helloWorld。 It is the first step that is troublesome. 这是第一步很麻烦。 :) :)

Main.c MAIN.C

#include <stdio.h>
#include "AS3.h"

static AS3_Val addNumber(void* self, AS3_Val args)
{
        double num1 = 0.0;
        double num2 = 0.0;

        AS3_ArrayValue( args, "DoubleType, DoubleType",
                       &num1, &num2);

        double sum = num1 + num2;
        return AS3_Number(sum);
}

static AS3_Val helloString(void* self, AS3_Val args)
{
        char *str = "Hello, Alchemy!";
        return AS3_String(str);
}


int main ()
{

        // define the methods exposed to ActionScript
    // typed as an ActionScript Function instance
    AS3_Val addNumberMethod = AS3_Function(NULL, addNumber);
        AS3_Val helloStringMethod = AS3_Function(NULL, helloString);

    // construct an object that holds references to the functions
    AS3_Val result = AS3_Object("addNumber: AS3ValType, helloString: AS3ValType",
                                    addNumberMethod,
                                    helloStringMethod);

    // Release
    AS3_Release(addNumberMethod);
        AS3_Release(helloStringMethod);

    // notify that we initialized -- THIS DOES NOT RETURN!
    AS3_LibInit(result);

    // should never get here!
    return 0;

}


compile using $ main.c -O3 -Wall -swc -o HelloAlchemy.swc 使用$ main.c -O3 -Wall -swc -o HelloAlchemy.swc

AS code: AS代码:

        import cmodule.HelloAlchemy.CLibInit;
        import mx.controls.Alert;

        private var loader:CLibInit;
        private var lib:Object;

        private function init():void
        {
            loader = new CLibInit;
            lib = loader.init();
        }
        protected function button1_clickHandler(event:MouseEvent):void
        {
            Alert.show(String(lib.addNumber(Number(3),Number(5)))); 
        }

        protected function helloStringButton_ClickHandler(event:MouseEvent):void
        {
            var str:String = String(lib.helloString());
            Alert.show(str);
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM