1 Reply Latest reply: Apr 26, 2012 2:46 AM by Bharat Patel RSS

    Improve video quality when using NetConnection

    Macnimation Community Member

      I have created a small video broadcast app using Flash PRofessional as it was getting tedious sending users FMLE and providing them with instructions on streaming their camera to my FMS.

       

      The application works fine but I have no control over the size of the video or the quality.

       

      When it streams, the video is blocky and pixelated.

       

      Could anyone help and provide information on adding code to control the quality and video size?

       

      code:

       

      var nc:NetConnection = new NetConnection();

      nc.client = this;

      nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);

      nc.connect("rtmp://localhost/livecast/", "The Trainer");

       

      function onMetaData(info:Object):void {}

      function onCuePoint(info:Object):void {}

      function asyncErrorHandler(event:AsyncErrorEvent):void {}

      function onSecurityError(evt:SecurityErrorEvent):void{}

       

       

      function onNetStatus(eventObj:NetStatusEvent):void {

          switch(eventObj.info.code){

              case "NetConnection.Connect.Success":

                

                  out_ns = new NetStream(nc);

                  out_ns.addEventListener(NetStatusEvent.NET_STATUS, onMetaData);

                  out_ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);

                  out_ns.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);

                  statusText.appendText(String.fromCharCode(13)+

                                        eventObj.info.code+

                                        String.fromCharCode(13)+

                                        "You are Connected! "+String.fromCharCode(13)+

                                        "-----------------------------"+String.fromCharCode(13));

                  setupBroadcast();

                  break;       

              case "NetConnection.Connect.Failed" || "NetConnection.Connect.Rejected":

                  statusText.appendText(String.fromCharCode(13)+

                                        eventObj.info.code+String.fromCharCode(13));

              break;

          }

      }

       

      function setupBroadcast():void {

        

          var local_cam:Camera = Camera.getCamera();

          out_ns.attachCamera(local_cam);

             

          var live_mic:Microphone = Microphone.getMicrophone();

        

          out_ns.attachAudio(live_mic);

         

          videoOut.myVid.attachCamera(local_cam);

          out_ns.publish("technical", "live");

      }