Search code examples
flashframemovie

extract a frame from a flash movie


I have a flash player playing a .flv video file

How could I reproduce this behaviour : when client press stop, catch the current frame ; kill the player ; display the last frame (previously caught) instead

Any solution would be fine (AS, PHP, JS, etc.), though it cannot be only server sided because I don't know in advance what frame will be needed.


Solution

  • Here is a simplified version:

    var flv:FLVPlayback = new FLVPlayback();
    var bmd:BitmapData = new BitmapData(flv.width, flv.height);
    var bm:Bitmap;
    
    function captureFrame():void {
        flv.stop();
        bmd.draw(flv);
        bm = new Bitmap(bmd);
        addChild(bm);
        // kill video and player here
    }
    

    Depending on where you're hosting the video, you may have some cross-domain issues with using BitmapData. But, assuming you have full control, this should work.