Search code examples
actionscript-3videoloopsbuffering

Looping Video Buffer in ActionScript3


I'm trying to create an AS3 app with looping, seamless video background. The background is loaded from an flv. The problem thus far is with the seamless bit, because all the video looping tactics I've come accross regarding AS3 always seem to have that short but noticeable pause at the end of the video before going back to the beginning and playing again.

The best way I've determined to deal with this is to play a video and buffer the video frames as BitmapData objects into a queue of a defined length (without adding the video to stage). This way Rendering the video would then really involve popping each of those BitmapDatas into a Bitmap object attached to my stage in a timed manner, which then gets drawn.

Sort of like:

/*VideoBufferer loops the input video and queues frames and then updates*/
var vidbuffer:VideoBufferer = new MyVideo("video.flv",outputImage)

var outputImage:Bitmap = new Bitmap();
stage.addChild(outputImage);

//forgive syntax, this is pseudoCode
timed process that happens X times per second{
  outputImage.bitmapData = vidbuffer.popBitmapData(); //returns bitmap data from the queue
}

I don't care about sound.

However I seem to not know how to implement this desired VideoBufferer class as I don't know how to play a video without adding it to stage and grabbing frames from it. Dows anyone know of any such class out there that already does this or could someone give me pointers on how to implement the frame grabbing side of VideoBufferer?

Thanks


Solution

  • I know this is a very late answer, but I have a solution for seamless flv playback, described here: http://blog.redannick.com/seamlessly-looping-video-files-in-as3-with-netstream-appendbytes/

    example code on a gist here: https://gist.github.com/redannick/7772246