is it possible to extract raw audio or video data from netstream before data is sent to backend media server via RTMP. so I can massage on the raw data? such as convert asao audio to PCM.
You can try using ActionScript 3.0 programming to extract raw audio
To extract raw audio, use the ActionScript 3.0 programming. To access data, call SoundMixer.computeSpectrum() on the client.
function extract(target:ByteArray, length:Number, startPosition:Number = -1 ):Number;
Where :
*target: A ByteArray object in which the extracted sound samples should be placed.
*length: The number of sound samples to extract. A sample contains both the left and right channels - that is, two 32-bit floating point values.
*startPosition: The sample at which extraction should begin. If you don't specify a value, the first call to extract() starts at the beginning of the sound; subsequent calls without a value for startPosition progress sequentially through the sound.
*extract() returns the number of samples which could be retrieved. This might be less than the length you requested at the very end of a sound.
I am posting an example by Peter deHaan for better understanding
var url:String = "http://www.helpexamples.com/flash/sound/song3.mp3";
var request:URLRequest = new URLRequest(url);
var s:Sound = new Sound();
s.addEventListener(Event.COMPLETE, completeHandler);
s.load(request);
var song:SoundChannel = s.play();
song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
var ba:ByteArray = new ByteArray();
var gr:Sprite = new Sprite();
gr.x = 20;
gr.y = 200;
addChild(gr);
var time:Timer = new Timer(50);
time.addEventListener(TimerEvent.TIMER, timerHandler);
time.start();
function completeHandler(event:Event):void {
event.target.play();
}
function soundCompleteHandler(event:Event):void {
time.stop();
}
function timerHandler(event:TimerEvent):void {
SoundMixer.computeSpectrum(ba, true);
var i:int;
gr.graphics.clear();
gr.graphics.lineStyle(0, 0xFF0000);
gr.graphics.beginFill(0xFF0000);
gr.graphics.moveTo(0, 0);
var w:uint = 2;
for (i=0; i<512; i+=w) {
var t:Number = ba.readFloat();
var n:Number = (t * 100);
gr.graphics.drawRect(i, 0, w, -n);
}
}
The sound data from a microphone or from RTMP streams do not pass through the global SoundMixer object,
the
SoundMixer.computeSpectrum() method will not return data from those sources. Also, If one or more of the
sounds being played come from sources outside the current content sandbox, security restrictions will cause the
SoundMixer.computeSpectrum()
method to throw an error.
+