Skip navigation
actionsketch
Currently Being Moderated

FLV in flash player stuttering

May 24, 2013 3:43 PM

Tags: #flash #video #flv #actionscript #stuttering

My FLV plays smoothly in VLC, Windows Media Player and Adobe Media Player.

 

 

If I load the same movie into flash, either by streaming, embedding, using software rendering or hardware rendering... it stutters uncontrollably. Here's my code:

 

 

package

{

    import flash.display.Sprite;

    import flash.events.AsyncErrorEvent;

    import flash.events.NetStatusEvent;

    import flash.events.StageVideoAvailabilityEvent;

    import flash.media.StageVideo;

    import flash.media.StageVideoAvailability;

    import flash.media.Video;

    import flash.net.NetConnection;

    import flash.net.NetStream;

 

 

    [SWF(width='760',height='500')]

    public class VideoPlayer extends Sprite

    {

        [Embed(source = "_example.flv", mimeType = "application/octet-stream")]

        private var VideoBytes:Class;

 

 

        private var _netStream:NetStream;

 

 

        public function VideoPlayer()

        {

            var nc:NetConnection = new NetConnection();

            nc.addEventListener(NetStatusEvent.NET_STATUS , onStreamStatus);

            nc.connect(null);

            _netStream = new NetStream(nc);

            _netStream.addEventListener(NetStatusEvent.NET_STATUS, onStreamStatus);

            _netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);

            _netStream.client = this;

 

 

            //playNormally();

            //playEmbedded();

            playHardwareAccelerated();

        }

 

 

        private function playEmbedded():void

        {

            var video:Video = new Video(stage.stageWidth, stage.stageHeight);

            video.attachNetStream(_netStream);

            addChild(video);

 

 

            _netStream.play(null);

            _netStream.appendBytes(new VideoBytes());

        }

 

 

        private function playNormally():void

        {

            var video:Video = new Video(stage.stageWidth, stage.stageHeight);

            video.attachNetStream(_netStream);

            addChild(video);

 

 

            _netStream.play("_example.flv");   

        }

 

 

        private function playHardwareAccelerated():void

        {

            if( !stage.stageVideos.length ) stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILA BILITY, onStageVideoState);

            else onStageVideoState(null);

        }

        private function onStageVideoState(e:StageVideoAvailabilityEvent):void{

            if(e == null || e.availability == StageVideoAvailability.AVAILABLE){

                var stageVideo:StageVideo = stage.stageVideos[1];

                stageVideo.attachNetStream(_netStream);

                _netStream.play("_scene.flv"); 

            }

            else trace("StageVideo Unavailable");

        }

 

 

        public function asyncErrorHandler(event:AsyncErrorEvent):void { trace(event.text); }

        public function onStreamStatus(e:NetStatusEvent):void { trace(e.info.code); }

        public function onMetaData( info:Object ) : void { trace("onMetaData:"); traceObject(info, 1); }

        public function onCuePoint( info:Object ) : void { trace("onCuePoint:"); traceObject(info, 1); }

        public function onXMPData( info:Object ) : void { trace("onXMPData:"); traceObject(info, 1); }

        public function onLastSecond( info:Object ) : void { trace("onLastSecond:"); traceObject(info, 1); }

 

 

        public function traceObject(obj:Object, indent:uint = 0):void

        {

            var indentString:String = "";

            for(var i:uint = 0; i < indent; i++) indentString += "\t";

 

 

            if(obj == null) trace(indentString + " null");

            else{

                var isEmpty:Boolean = true;

                for(var prop:String in obj){

                    var val:* = obj[prop];

                    isEmpty = false;

                    if(typeof(val) == "object"){

                        trace(indentString + " " + prop + ": [Object]");

                        traceObject(val, indent + 1);

                    }

                    else trace(indentString + " " + prop + ": " + val);

                }

                if( isEmpty ) trace(indentString + " empty");

            }

        }

 

 

    }

}

 

 

and here's my FLV

 

 

I'm at a loss for what to do about this... and the answer might very well be that the flash FLV renderer isn't good enough to display my flv smoothly, unlike every other FLV player I've tried. But, this is a big deal for my project and I have got to find a solution.

 

 

Thanks!

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points