Friday, June 10, 2011

Acoustic Echo Cancelation working

Acoustic Echo Cancellation is part of Flash Player 10.3.
Users are able to enjoy live audio/video communication without the risk of acoustic feedback. Previous post on Flash vs. AEC.

It's a bit tricky to implement yet.

First get the latest Flash Player Content Debugger 10.3.181.22, not the incubator version.

With the current Build of the Flex SDK (4.5.0.20967) that's also shipped with Flash Builder 4.5, you need to add this playerglobal.swc to the SDK's /frameworks/libs/player/10.3/ directory.

Add additional mxmlc compiler arguments with your IDE or directly to the actionscript properties file.
// Specifies the version of Flash Player that you want to target with the application, targets the correct playerglobal.swc.
-target-version=10.3

// Specifies the SWF file format version of the output SWF file.
-swf-version=12

Then use this code snippet in your ActionScript Class.
...
// Gets reference to the Microphone instance with enhanced options.
var microphone:Microphone = Microphone.getEnhancedMicrophone(deviceIndex);
microphone.codec = SoundCodec.SPEEX;
var enhancedOptions = new MicrophoneEnhancedOptions();

// Sets AEC mode for users without a headset.
enhancedOptions.mode = MicrophoneEnhancedMode.FULL_DUPLEX;
microphone.enhancedOptions = enhancedOptions;
...

Have fun!

Example ChatRoom using Red5 Media Server running on an Amazon EC2 instance and Adobe Cirrus rendezvous service. It's based on the direct RTMFP peer-to-peer connection feature of Adobe Flash Player 10

2 comments:

  1. Hi,

    is the "flash player option => reduce echo" mandatory? or it should work anyway?

    i make a 1a1 videochat inside the same swf.

    one netconnection with attached camera makes a net streams to a FMS and another netstream reproduce the other streams.

    i have huge echo issues with flash player 11.5.

    the streams must to be inside the same swf?

    any advice?

    thanks

    bye

    ReplyDelete
    Replies
    1. Hi Andrea,

      here's a good description on the AEC feature.
      You should use Microphone.getEnhancedMicrophone and assign MicrophoneEnhancedMode.FULL_DUPLEX via the MicrophoneEnhancedOptions as described above.
      Additionaly you should set NetStream.bufferTime to a minimum value and Microphone.framesPerPacket to 1.
      This will minimize the clientside feedback.

      I'm not sure why you are using FMS, with Adobe Cirrus and the direct RTMFP peer-to-peer connection feature you will save much bandwidth. Because of the client-to-client connection there will be less delay because the stream doesn't have to pass media server.

      I don't think it's necessary to invoke the Microphone Settings dialog and point the user to check the 'Reduce Echo' checkbox if you've done what I described above.

      I guess at development time you test this feature with two clients / applications / swfs inside one browser. Of course this will produce some additional delay and maybe more echo & feedback too.

      Kind Regards
      Joachim

      Delete