Search code examples
videoactionscriptflex4thumbnails

Get random (or first) frame from video using flex


I am developing an application for recording videos and previewing them as tilelist. Is there any way to capture a frame of the video to use as a thumbnail in my list? I'm using Flex 4.5.


Solution

  • what i was searching for was the following:

            private function capture(filename:String):void
            {   
                var bitmapData:BitmapData = new BitmapData(videoDisplay.width, videoDisplay.height);            
                bitmapData.draw(videoDisplay,new Matrix());
    
                var bitmap : Bitmap = new Bitmap(bitmapData);
                var jpg:JPEGEncoder = new JPEGEncoder();
                var ba:ByteArray = jpg.encode(bitmapData);
                var newImage:File = File.desktopDirectory.resolvePath("foldername/"+filename+".jpg");
    
                fileStream = new FileStream();
                fileStream.open(newImage, FileMode.UPDATE);
                fileStream.writeBytes(ba);
                fileStream.close();
    
    
            }
    

    which is a method called when the user clicks to record..so i grab a photo as a thumb! i hope the above will help others too who look for something similar... Thanks a lot!