meghana
meghana

Reputation: 907

AS3 - how to change speed of FLVPlayBack

i need to play FLVPlayback Video at different speeds , can i do this by changing frame-rate of FLVPlayBack and how can i achieve this using as3?

Or is there any other method to do the same? Please Suggest me.

Meghana

Upvotes: 0

Views: 3980

Answers (3)

stevendesu
stevendesu

Reputation: 16801

Chiming in a bit late, but there's actually a way to play an FLV in slow motion without constantly seeking or playing/pausing repeatedly. It's just extremely involved.

If you open the .flv file using a URLStream then you can access the bits. Scan for the timestamp, re-write it, then pass the new ByteArray to a NetStream in data generation mode. Using this you can play video at any frame rate - although the ability to play audio in slow / fast motion depends on the codec being used. The layout of an FLV packet is something like:

  1. "FLV"
  2. packet length
  3. packet type (audio / video / metadata)
  4. timestamp
  5. additional headers
  6. data

To change the audio sample rate you would need to muck with the data - much more convoluted than just changing timestamps. I know, for instance, that AAC data has a header which specifies the sample rate as an index into an array:

[ 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 ]

So if you had 44.1 kHz audio (sample rate index = 4) you could play at half speed by declaring the sample rate to be 22.05 kHz (sample rate index = 7)

Upvotes: 1

Sr.Richie
Sr.Richie

Reputation: 5740

There's no way to change the framerate of a video in AS3, it will be always rendered at the video's native framerate.

The only way I can think to do it is to write some sort of function that calculates how to move the playhead, but I cannot guarantee the result of this approach.....

EDIT: As you ask in your comment, YES, you can do it by controlling the NetStream. Here you have the solution: http://younsi.blogspot.it/2009/03/how-to-play-video-in-flash-in-slow.html

Upvotes: 1

Swati Singh
Swati Singh

Reputation: 1863

//set your framerate here whatever you want
stage.frameRate = 30;
var FRAMERATE : Number = stage.frameRate;

btnActual.addEventListener(MouseEvent.CLICK, videoSpeed);
btn15.addEventListener(MouseEvent.CLICK, videoSpeed);
btn5.addEventListener(MouseEvent.CLICK, videoSpeed);

function videoSpeed (myEvent:Event):void{

    var newFrameRate = Number(myEvent.target.value);    

    stage.frameRate = newFrameRate;

}

Upvotes: 0

Related Questions