4 Replies Latest reply on Jun 10, 2010 9:14 AM by cyber0897

    is there a way i can take snapshots of videos to create thumbnails??

    cyber0897 Level 1

      hey guys...so im creating a video library... and i was wondering if there is a way i can take snapshot of a frame in the video?? or better yet create a video player with a scrubber and let the user scrub thru the video and pick a frame to take the snapshot of??

       

       

      any help would be great!!!

       

      thanks in advance!

        • 1. Re: is there a way i can take snapshots of videos to create thumbnails??
          BhaskerChari Level 4

          Hi you can make use of the BitMap API to take the snapshot of the BitmapData...

           

          Check out the below code:

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application 
              xmlns:mx="http://www.adobe.com/2006/mxml" 
              xmlns:graphics="com.cynergysystems.graphics.*" 
              xmlns="*" layout="absolute"
              creationComplete="onCreationComplete()"
              >
              
              <mx:Script>
                  <![CDATA[
                      import mx.core.UIComponent;
                      import mx.controls.Alert; 
                      
                      private function onCreationComplete() : void
                      {
                          this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
                      }
          
                      private function onEnterFrame( event : Event ):void
                      {
                          bitmapDataTarget.source = new Bitmap( getUIComponentBitmapData( videoDisplay ) );
                      }
                      
                      private function getUIComponentBitmapData( target : UIComponent ) : BitmapData
                      { 
                          var bd : BitmapData = new BitmapData( target.width, target.height );
                          var m : Matrix = new Matrix();
                          bd.draw( target, m );
                          return bd;  
                      }
                      
                  ]]>
              </mx:Script>
              
              <mx:HBox width="100%" height="100%"
                  paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5" >
          
                  <mx:Panel   
                      title="FLV Video"
                      id="videoContainer" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                      
                      <mx:VideoDisplay id="videoDisplay" source="BigWavesurfing.flv/>
                      
                  </mx:Panel>
                  
                  <mx:Panel  
                      title="Mirror Image:" layout="absolute" horizontalScrollPolicy="off" verticalScrollPolicy="off"
                      width="{videoContainer.width}" height="{videoContainer.height}" >
                      
                      <mx:Image id="bitmapDataTarget" />    
                      
                  </mx:Panel>
              
              </mx:HBox>
              
              
          </mx:Application>

           

          If this post answers your question or helps, please kindly mark it as such.


          Thanks,

          Bhasker Chari

          • 2. Re: is there a way i can take snapshots of videos to create thumbnails??
            cyber0897 Level 1

            thanks so much Bhasker! that helped me immensely!

            • 4. Re: is there a way i can take snapshots of videos to create thumbnails??
              cyber0897 Level 1

              i actually changed my code a little to do something like this

               

              var temp:ImageSnapshot = new ImageSnapshot();
              var snapshot:BitmapData = ImageSnapshot.captureBitmapData(videoPlayer.videoDisplay);
              imageTag.source = new Bitmap(snapshot);
              

               

              that worked like a charm...!