问题
In action script how to convert using audio encoder a recorded byte array from microphone to MP3
public var recordedData:ByteArray;
recordedData.writeBytes(sample.data, 0, sample.data.bytesAvailable);
How to save recordedData to mp3 using audio encoder
回答1:
You find yourself an MP3 encoding library that runs in the Flash player. A simple google search finds Shine to be pretty popular. Another option is to stream the audio up to the server and encode there.
Depending on your environment, you might be able to use something like LAME if you are in Air and are willing to build a native extension to do the encoding.
EDIT
If you are using Shine, I found an example in the project that implies that encoding is easy:
private var mp3Encoder:ShineMP3Encoder;
private function encodeClicked(event:Event):void {
mp3Encoder = new ShineMP3Encoder(wavLoader.data);
mp3Encoder.addEventListener(Event.COMPLETE, mp3EncodeComplete);
mp3Encoder.addEventListener(ProgressEvent.PROGRESS, mp3EncodeProgress);
mp3Encoder.addEventListener(ErrorEvent.ERROR, mp3EncodeError);
mp3Encoder.start();
}
private function saveClicked(event : MouseEvent) : void {
mp3Encoder.saveAs();
}
来源:https://stackoverflow.com/questions/10448179/as3-audiioencoder-to-convert-to-audio