• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 554
  • Last Modified:

Changing the framerate playback of VideoFile in AS3 / Air App

Hi, I'm trying to reproduce a video file using AIR.

I'm trying to set the framerate of the playback using the import flash.net.NetStream and flash.media.Video, specifically the NetStream.receiveVideoFPS(fps:Number) but it is not working.

Please help,


package etc.patexp
	import flash.display.Sprite;
	import flash.events.NetStatusEvent;
	import flash.events.SecurityErrorEvent;
	import flash.events.AsyncErrorEvent;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.net.NetConnection;
	import flash.net.NetStream;
	import flash.media.Video;
	 * ...
	 * @author Daniel Rodriguez
	public class Main extends Sprite 
		private var videoURL:String = "video.flv";
        private var connection:NetConnection;
        private var stream:NetStream;
        public function Main():void
            connection = new NetConnection();
            connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
            connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
        private function netStatusHandler(event:NetStatusEvent):void 
            switch (event.info.code) 
                case "NetConnection.Connect.Success":
					stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
                case "NetStream.Play.StreamNotFound":
                    trace("Unable to locate video: " + videoURL);
        private function connectStream():void 
            stream = new NetStream(connection);
            stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
            stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
			stream.client = new CustomClient();
            var video:Video = new Video();
        private function securityErrorHandler(event:SecurityErrorEvent):void 
            trace("securityErrorHandler: " + event);
        private function asyncErrorHandler(event:AsyncErrorEvent):void 
            // ignore AsyncErrorEvent events.
		private function onKeyDown(evt:KeyboardEvent):void
class CustomClient {
    public function onMetaData(info:Object):void {
        trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);
    public function onCuePoint(info:Object):void {
        trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type);

Open in new window

1 Solution
Aneesh ChopraCommented:
As per my understanding,

NetStream.receiveVideoFPS() method works only for the Streaming server video stream.
this method is available only to clients subscribed to the specified stream, not to the stream's publisher.

If you pass a value to the FPS parameter to limit the frame rate of the video, the RTMP server attempts to reduce the frame rate while preserving the integrity of the video. The server sends the minimum number of frames needed to satisfy the desired rate between every two keyframes.

here in your code,  there is no RTMP server in play, your code is not actually connecting to any Media server.
following line of code shows that you are loading video as progressive download not streaming download.


I hope it would be clear..

Aneesh Chopra

dornadAuthor Commented:

Funny, cause I'm not using a Streaming Video Server.  I'm just loading the file from the local hard disk.   All I need to do is slow-down or speed-up the video ?  

I thought that using fps would be the way to go here.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now