Tuesday, August 16, 2005

[FlashComm] Bandwith Management using Web Cam Motion Detection

We all known that most of FlashComm developver always fight with bandwith limitation. Lisa Larson also talk FlashComm Hit List on FlashCodersNY.org. I agree that using Audio and Video is really cool in FlashComm. But if you has limitation on bandwith then you will has problem. You can optimize your audio / mic and video / web cam using Peldi tools. But if that's still not enough then you can try to used motion detection of web cam to avoid sending video if nothing need to be sent (let's say the camere is idle). We can used Camera.onActivity, Camera.activityLevel, Camera.motionLevel, Camera.setMotionLevel() to detect motion on our web cam. Method:
Camera.setMotionLevel(sensitivity_motion_detection, time_interval);
Sample code:
// net connection nc = new NetConnection(); nc.connect("rtmp:/testCam"); // camera my_cam = Camera.get(); my_cam.onActivity = function(activity) {       trace("motion detection : "+activity);       if(!activity){             my_video.attachVideo( null );             ns.attachVideo( null ); // stop publishing       } else {             my_video.attachVideo( my_cam );             ns.attachVideo( my_cam ); // re publishing       } } my_cam.setMotionLevel(10, 1000); my_video.attachVideo(my_cam); // net Stream ns = new NetStream( nc ); ns.attachVideo( my_cam ); ns.publish("streams_", "live");
More details about using web cam motion detection you can find on LiveDocs.

1 comment:

Nice Guy said...

Neat that webcams can be used with Adobe Flash! See some of my experiments & samples on http://www.SillyWebcam.com .