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

I have a TGP site that I built In perl a long time ago and I decided I want to allow video uploads, too.

It wouldn't be hard to tweak my uploader to allowing mpg, avi or other video files but I did run across a question. I need to have a thumbnail of the movie (like how Youtube has) and was wondering if there was a module that could extract either the first frame or a frame at a specific interval that I could thumbnail.

Anyone know of such module that'll work with most video files?

Replies are listed 'Best First'.
Re: taking a frame from a movie
by Corion (Patriarch) on Oct 13, 2006 at 06:41 UTC

    Imagemagick and ffmpeg can extract single frames from movies. If you manage to install Image::Magick or the forked and supposedly more stable GraphicsMagick, you can access an .mpg stream as an array of images.

    I would go the easier way of using an external program to extract the images, like the convert program that comes with ImageMagick or GraphicsMagick, or ffmpeg.

    One random commandline I found for ffmpeg via Google was:

    ffmpeg -i swing.avi -vcodec png -vframes 1 -an -f rawvideo -s 320x240 +swing1.png
      I would go the easier way of using an external program to extract the images

      Given than someone has mentioned external programs, let's also add mplayer:

      mplayer -vo png:z=6 -frames 2 -ss 10:00

      Yes, -frames 2 for outputting one image. -ss specifies start time.

      --
      David Serrano

Re: taking a frame from a movie
by Khen1950fx (Canon) on Oct 13, 2006 at 03:52 UTC
Re: taking a frame from a movie
by stonecolddevin (Parson) on Oct 13, 2006 at 01:45 UTC

    Hmm...this is odd, nothing was readily available on CPAN that i could find...of course, this means nothing :-)

    I'd recommend at least checking out http://www.youtube.com/dev to see what kind of video manipulation methods they have...if you don't use it, you can at least see how they did it. I believe Google Video has an API out that could help out as well...

    meh.
Re: taking a frame from a movie
by blazar (Canon) on Oct 13, 2006 at 10:52 UTC
    It wouldn't be hard to tweak my uploader to allowing mpg, avi or other video files but I did run across a question. I need to have a thumbnail of the movie (like how Youtube has) and was wondering if there was a module that could extract either the first frame or a frame at a specific interval that I could thumbnail.

    I've done something like that manually with ImageMagick, but in that case it was and ad hoc job and I wanted to visually pick "significative" frames. I suppose that it would be relatively easy to automatize the process with Image::Magick.