Skip to main content
Participant
September 28, 2009
Question

Generate thumbs of video objects ?

  • September 28, 2009
  • 2 replies
  • 454 views

Hey guys!              

Didn't think this one is getting so tricky ...

I need the first frame of a video-object.

My first guess was to pause the netstream object immediately after the play method and use the seek / close methods when the bufferLength is > 0.1.

But I dont get a picture yet 😕😕 ...

Is there a more effecient way to to that? How do you guys solve that issue when you have to display video-thumbnails?

Thanks a lot

wambo (-:

Code:

    public class VideoThumb extends MovieClip
    {
       
        private var nc:NetConnection = new NetConnection();
        private var ns:NetStream;
        private var vid:Video = new Video(200,140);
        private var netClient:Object = new Object();
       
        private var prjInfo:ProjectInfo;
        private var _duration:Number;
       
       
       
        public function VideoThumb(pi:ProjectInfo){           
           
            this.prjInfo = pi;
                    
       
            this.buttonMode = true;
           
           
           
            /*### VIDEO SETUP ##########*/
            this.addChild(vid);
           
            nc.connect(null);
            ns = new NetStream(nc);           
                                   
                       
            addChild(vid);
           
            vid.attachNetStream(ns);
                       
           
            ns.play("assets/video/two.flv");
            ns.pause();
           
            ns.client = netClient;                       
                                           
           
            netClient.onMetaData = function(meta:Object)           
            {           
                    trace(meta.duration);
                    _duration = meta.duration;                                                               
            };
           
                       
            ns.addEventListener(NetStatusEvent.NET_STATUS, netstat);
            this.addEventListener(Event.ENTER_FRAME, loop);                        
           
           
        }
       
        private function loop(e:Event):void{
           
            if(ns.bufferLength >= 0.1){               
                ns.seek(0.1);
                ns.close();                                  
                this.removeEventListener(Event.ENTER_FRAME, loop);
            }
        }

}

This topic has been closed for replies.

2 replies

AttaBoy2
Inspiring
September 28, 2009

I use After Effects.  If you don't have a video editor there are some free ones out there I found a good avi editor a while back I can't recall its or find it on my system but I'm sure if I did a search for avi editors I would fing a good one.  I also use cnet downloads alot they have stuff rated and you can save time by not picking through garbage.

Inspiring
September 28, 2009

The most reliable way would be to create thumbnails manually as jpgs, pngs, etc and display them before the video starts. But if you need to display one of the first frames in the video you better off listening to NetStatusEvent and when event.info.code is NetStream.Buffer.Full - call seek(0) and pause(). Here is documentation:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/NetStatusEvent.html