8 Replies Latest reply on Apr 28, 2009 6:25 PM by ArmenGeo

    Streaming video using a web camera is choppy

    ArmenGeo

      Hello,

       

       

       

      I have an swf program built with flex which displays video from a web camera. The problem is that the the video is being displayed a bit choppy. You can see an example at https://www.completelyonlinetestserver.com/Flex/videobox.html. Try holding a piece of paper with writing in front of the camera and you will see that the writing is very choppy.

       

       

       

      What can I do to make the video clearer?  Any help would be very appreciated.

       

      Thanks

      Armen

       

       

        • 1. Re: Streaming video using a web camera is choppy
          injpix Level 3

          Are you using Flash Media Server with this?  Is it streaming thru a network?

           

          Anyways, I am unable to access that web page you posted, I get a 403 web error.  Perhaps that it might be your computer's lack of performace.  Have you tested this on anyother machines?

          • 2. Re: Streaming video using a web camera is choppy
            ArmenGeo Level 1

            Hi MyIP,

            Thank you for your reply.

             

            I am not using Flash Media Server.  The SWF file and also the html file are located on a unix box.  When the html file is called using a browser it accesses the files from the unix server.

             

            The URL I provided you was to our test server which only allows specific access by specific IP's.  Sorry, try this URL instead

            http://www.completelyonline.com/Flex/videobox.html.  Thanks again for your help.

            • 3. Re: Streaming video using a web camera is choppy
              injpix Level 3

              Ah...so this video is not streaming across any network.  The user simply hits this web page on the server which has an embedded SWF.  When the user allows FlashPlayer to have his/her web cam access then, the video is streaming, but only locally.  Without seeing any code, have you looked into the following Camera methods:

              setMode(width:int, height:int, fps:Number, favorArea:Boolean = true):void 
              setMotionLevel(motionLevel:int, timeout:int = 2000):void  
              setQuality(bandwidth:int, quality:int):void
              
              • 4. Re: Streaming video using a web camera is choppy
                ArmenGeo Level 1

                Hi myIP,

                I am trying to create the example code you refernced at http://livedocs.adobe.com/flex/3/langref/flash/media/Camera.html#includeExamplesSummary.  I've created a new actionscript project and replaced the code in the project wirth the example code given online.  The code comples just fine but doesnt display any video from the web camera.  Any thoughts?

                 

                Thanks again!

                • 5. Re: Streaming video using a web camera is choppy
                  injpix Level 3

                  Hmmm...I dont have the drivers installed on my computer for my web cam to work, but when I compile that example do get the trace output, "You need a camera.".  So that part works.  Below is the code ported into an MXML file.

                   

                  <?xml version="1.0" encoding="utf-8"?>
                  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                                  layout="absolute"
                                  applicationComplete="CameraExample();">
                       <mx:Script>
                            <![CDATA[
                                 
                            private var video:Video;
                          
                          public function CameraExample() 
                          {
                              stage.scaleMode = StageScaleMode.NO_SCALE;
                              stage.align      = StageAlign.TOP_LEFT;
                              
                              var camera:Camera = Camera.getCamera();
                              
                              if (camera != null) 
                              {
                                  camera.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
                                  video = new Video(camera.width * 2, camera.height * 2);
                                  video.attachCamera(camera);
                                  addChild(video);
                              } 
                              else 
                              {
                                  trace("You need a camera.");
                              }
                          }
                          
                          private function activityHandler(event:ActivityEvent):void {
                              trace("activityHandler: " + event);
                          }
                  
                            ]]>
                       </mx:Script>
                  </mx:Application>
                  
                  • 6. Re: Streaming video using a web camera is choppy
                    ArmenGeo Level 1

                    If I unplug the camera I get the same error message.  But when the camera is plugged in nothing happens.

                    • 7. Re: Streaming video using a web camera is choppy
                      ArmenGeo Level 1

                      Hi myIP,

                      I was able to create the following code which does turn the camera on.  However the feed is choppy.  Any thoughts?

                       

                      <?xml version="1.0" encoding="utf-8"?>
                      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:local="*" layout="absolute" creationComplete="initApplication()" fontFamily="Arial" backgroundAlpha="0" width="823" height="886" borderStyle="none">
                        <mx:VideoDisplay id="videoContainer"  x="305" y="147"  width="320" height="240"  borderStyle="solid"/>
                       <mx:Script>
                              <![CDATA[
                                public var camera : Camera ;
                                public var video : Video; 
                              public function initApplication()
                              {
                               camera = Camera.getCamera();
                                video  = new Video(camera.width*2, camera.height*2);  
                                   video.width = 320 ;
                                   video.height =240 ;  
                                   video.attachCamera(camera);  
                                   videoContainer.addChild(video);  
                              }   
                              ]]>
                          </mx:Script>
                      </mx:Application>
                      
                      
                      • 8. Re: Streaming video using a web camera is choppy
                        ArmenGeo Level 1

                        Ok I figured out the fix.  I needed to add the following after camera = Camera.getCamera();

                                     camera.setKeyFrameInterval(1);
                                     camera.setLoopback(0);
                                     camera.setMode(320,240,100,0);
                                     camera.setQuality(0,100);