Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi I'm trying to extract a still image from a frame of an .avi film taken by my digital camera. I'd like to use it as a thumbnail for the file on a website. I've had a play with Image::Magick and a search through CPAN, but I can't find a module that will let me do this. Does anybody have any ideas or pointers? Thanks!

Replies are listed 'Best First'.
Re: Extracting a frame from an avi
by ptkdb (Monk) on Nov 10, 2003 at 21:43 UTC
    AVI, I believe is a proprietary format, owned by Microsoft. You may have better luck finding a C# class that can handle it. Microsoft typically gives you something like a 30-90day trial of their .NET development environment.

    Might not be a bad way to learn C#.

    IMHO, C# was invented because Sun Microsystems and a judge told microsoft to quit messing with Java.

    It's not a bad little language, although lacking the elegance of perl, and doing several things that seem fairly strange and are probably meant to say 'THIS IS NOT JAVA!'

    I took a quickie seminar in C# last year, and it was there that I was introduced to the Orwellian term microsoft was casting about as they evangelized their .NET platform:

    Unmanaged Code

    Referring to code that was found in traditional .obj, .o and executable files, but in effect referring to anything that wasn't produced with .NET.

      Hi, thanks ptkdb. I think after some more research I'm barking up the wrong tree trying to extract the frame myself. However in Windows the thumbnail of the 1st frame of the film is used for the icon of the file. This thumbnail is stored in the thumbs.db file which appears in the directory, which might be a better place to look at finding this image. Anybody any ideas on the thumbs.db set up? Thanks
Re: Extracting a frame from an avi
by ChemBoy (Priest) on Nov 10, 2003 at 23:06 UTC

    There are open-source tools that let you break down the frames of a motion-JPEG AVI file into individual files, as well as split out the sound track. I would imagine that these tools can do what you want—unfortunately, they don't necessarily do it in a way that's very convenient.

    Somebody could get out the XS tools and put together an Perl interface to the relevant libraries, of course, but it doesn't look like anybody has (though somebody on that project has the expertise, since there's a YUV4MPEG Perl module). If you're so inclined, though, do please post your progress back here: I'm sure you're not the only one who has wanted to do this. (Very sure, in fact.) But failing that, you may well be able to cobble something together using the MJPEG tools linked above.



    If God had meant us to fly, he would *never* have given us the railroads.
        --Michael Flanders

Re: Extracting a frame from an avi
by wolis (Scribe) on Nov 10, 2003 at 23:15 UTC
    I Use 'Paint Shop Pro' (Windows shareware available www.jasc.com) with its 'Animation Shop' application.

    This reads in an AVI and you can cut one of the frames and paste into PSP and save as a JPG.

    Im sure there are many other AVI manuplation tools around

    ___ /\__\ "What is the world coming to?" \/__/ www.wolispace.com
Re: Extracting a frame from an avi
by ant9000 (Monk) on Nov 11, 2003 at 13:42 UTC
    I've been using mplayer for almost all of my multimedia needs... it reads almost anything you can throw at it, it's blazingly fast, it is rock solid and configurable. It even has an almost working GUI, should you like to have one... I don't :-)
    Coming to your problem: it supports a JPEG video output mode that saves each video frame as a separate jpeg image; it's not difficult to extract just a single frame, if that's what you want:
    mplayer -vo jpeg -frames 1 _video_file_

    Since everything can be configured and used from the command line, automating the work with a few Perl strokes should be an almost trivial task.
    HTH,
    Ant9000