Copy link to clipboard
Copied
Hi,
is there a special way to use SampleDataEvent with NetStream.play() ?
I would like to apply my own audio effect to NetStream thanks
Copy link to clipboard
Copied
if you're using felarca's flvencoder, you're using the bitmapdata class to create the flv.
and i had no trouble, using his class, creating an flv using a loaded sound and graphics generated by computespectrum, http://kglad.com/Files/forums/test.flv
Copy link to clipboard
Copied
I use leelib classes I modified. didn't know felarca flvencoder, I will take a look soon.
sorry for the delay, I'm so busy to debug other things... will be back soon
Copy link to clipboard
Copied
Hi Keith, sorry for the long delay,
do you have any link about felarca flvencoder to try computeSpectrum audio grab?
my goal is to grab all audio played int the swf (sounds as well as netstream)
the mix it into a bytearray to save it as an flv.
thanks
Copy link to clipboard
Copied
i'm not sure what you're asking.
i gave a link to an flv created using the flvencoder class. the flv shows a brief snippet of queen's bohemian rhapsody and a visual created using computespectrum.
Copy link to clipboard
Copied
for a graphic representation computeSpectrum() is ok, but my goal is to grab
the raw audio data from it and save the audio only in a wave file
Copy link to clipboard
Copied
how do you extract the audio from the data?
Copy link to clipboard
Copied
like that
package{
import flash.display.Sprite;
import flash.display.Graphics;
import flash.events.Event;
import flash.events.NetStatusEvent;
import flash.events.AsyncErrorEvent;
import flash.events.TimerEvent;
import flash.media.Sound;
import flash.media.Video;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.utils.ByteArray;
import flash.utils.Endian;
import flash.utils.Timer;
import flash.text.TextField;
public class SoundMixer_computeSpectrumExample extends Sprite{
private var audioResult:Sound;
private var server:String = "rtmp://myservert/vod";
private var stream:String = "mp4:sample1_150kbps.f4v";
private var nc:NetConnection;
private var ns:NetStream;
private var audioTimer:Timer;
private var recTimer:Timer;
private var bytes:ByteArray = new ByteArray();
private var wavArray:ByteArray = new ByteArray();
private const CHANNEL_LENGTH:uint = 256;
public function SoundMixer_computeSpectrumExample(){
nc = new NetConnection();
nc.connect(server);
nc.addEventListener(NetStatusEvent.NET_STATUS,onNetStatus);
nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR,function(event:AsyncErrorEvent):void{trace(event.toString())});
nc.client = this;
audioTimer = new Timer(86.1328125);
audioTimer.addEventListener(TimerEvent.TIMER,audioTimerHandler);
recTimer = new Timer(10000,1);
recTimer.addEventListener(TimerEvent.TIMER,recTimerHandler);
//wavArray.endian = Endian.LITTLE_ENDIAN;
}
private function onNetStatus(event:NetStatusEvent):void{
var code:String = event.info.code;
trace(code);
switch(code){
case "NetConnection.Connect.Success":
ns = new NetStream(nc);
ns.client = this;
ns.bufferTime = 0;
ns.addEventListener(NetStatusEvent.NET_STATUS,onNetStatus);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR,function(event:AsyncErrorEvent):void{});
ns.play(stream);
break;
case "NetStream.Play.Start":
audioTimer.start();
recTimer.start();
break;
case "NetStream.Buffer.Flush":
if(last_status == "NetStream.Play.Stop"){
audioTimer.stop();
}
break;
}
last_status = code;
}
public function onBWDone(){
//
}
private function audioTimerHandler(event:TimerEvent):void{
SoundMixer.computeSpectrum(bytes,true,1);
for(var i:uint=0;i<CHANNEL_LENGTH; i++){
wavArray.writeByte(bytes.readByte());
}
for(i=CHANNEL_LENGTH;i>0;i--){
wavArray.writeByte(bytes.readByte());
}
}
private function recTimerHandler(event:TimerEvent):void{
ns.close();
audioTimer.stop();
wavArray.position = 0;
// TODO: how to replay the audio?
}
}
}
Copy link to clipboard
Copied
you need to extract the audio from the video. i don't know how to do that.
Copy link to clipboard
Copied
on computeSpectrum doc it says "raw sound data", can be PCM but wav is LITTLE_ENDIAN as I know
my main goal being to grab all audio playing in the swf (netstream,sound object etc...)
into a bytearray and convert it in wav.
Copy link to clipboard
Copied
What I need to do is to catch on every frame or timer the audio data
to save it on a file locally in FLV as PCM. Everything is working well but the audio, samples are too short
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more