[Red5] SoundMixer.computeSpectrum rtmp livestream

John Hauf j at hauf.org
Sat Nov 28 07:30:29 PST 2009


I did noting special. I'm using red5 0.9 RC1 and the Flash Player
10.0.32.18 Debugger on both sides.

On the client that plays the stream I use:
...
var ns:NetStream = new NetStream(netConnection);

//This line is needed - otherwise computeSpectrum
//is not working on live streams.
ns.bufferTime = 0.01;

ns.client = this;
ns.play("my_stream_name");
...

the visualization is done by computeSpectrum in onEnterFrame:
...
var byteArray:ByteArray = new ByteArray();
SoundMixer.computeSpectrum(byteArray, true);
...

On the publishing side I use:
...
this.micStream = new NetStream(this.netConnection);
this.micStream.addEventListener(NetStatusEvent.NET_STATUS,this.netStatusHandler);
this.micStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR,this.asyncErrorHandler);
this.mic = Microphone.getMicrophone();
this.mic.codec = SoundCodec.SPEEX;
this.mic.setUseEchoSuppression(true);				this.mic.encodeQuality = 10;
this.mic.rate = 22;
				this.mic.addEventListener(ActivityEvent.ACTIVITY, this.onMicActivity);
this.mic.addEventListener(StatusEvent.STATUS, this.onMicStatus);

this.mic.soundTransform.volume = 100;
//No camera needed
//this.micStream.attachCamera(cam);
this.micStream.attachAudio(mic);
this.micStream.publish("my_stream_name", "record");
...

In the red5-web.xml configuration I use this to allow sample access of
the live sound in the flash player (If you omit this you will get a
sandbox security exception):
...
<bean id="rtmpSampleAccess" class="org.red5.server.stream.RtmpSampleAccess">
	<property name="audioAllowed" value="true"/>
	<property name="videoAllowed" value="true"/>
</bean>
...

As you can see the only "unusual" thing is the bufferTime on the client
side. If I comment out this line SoundMixer.computeSpectrum does only
put "0" values in the byteArray.

Hope that helps,
John




Dan Daemon wrote:
> Hello,
> 
> Can you explain more better how did you make it work please?
> 
> Dan
> 
> On Fri, Nov 27, 2009 at 7:57 PM, John Hauf <j at hauf.org> wrote:
>> Hello,
>>
>> now I found a solution/workaround for this issue: When you set the
>> netstream.bufferTime to a non zero value (even a very small one like
>> 0.01), SoundMixer.computeSpectrum works well with the live stream.
>>
>> John
>>
>> John Hauf wrote:
>>> Hello,
>>>
>>> I'm new to this list and want to thank all developers of red5 for the
>>> great software.
>>> I'm devloping my first project with flex and red5 at the moment and try
>>> to use SoundMixer.computeSpectrum on a rtmp live stream. When I check
>>> the byteArray which is filled by computeSpectrum, it only contains zero
>>> values.
>>> If I use computeSpectrum with a rtmp file-stream, stored in the
>>> "streams" directory of the red5-server, everything works perfect. The
>>> only thing I change is the name of the stream in the
>>> netstream.play()-method.
>>> Does anybody have an idea why computeSpectrum is not working with the
>>> live stream?
>>>
>>> Thank you,
>>> John
>>>
>>> _______________________________________________
>>> Red5 mailing list
>>> Red5 at osflash.org
>>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>>
>>>
>> _______________________________________________
>> Red5 mailing list
>> Red5 at osflash.org
>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>
> 
> _______________________________________________
> Red5 mailing list
> Red5 at osflash.org
> http://osflash.org/mailman/listinfo/red5_osflash.org
> 
> 



More information about the Red5 mailing list