Create an Image Preview from a Video

By  on  

Visuals are everything when it comes to media.  When I'm trying to decide whether to watch a video on Netflix, it would be awesome to see a trailer of some kind, but alas that isn't available.  When I'm looking to download a video on my computer, it'd be awesome to have one single, condensed preview image which has thumbnails of every {x} seconds/minutes of the video to see whether it's worth watching.  I was sniffing around to find an app or easy way to do it but couldn't find anything, but I did find a way to use two utilities, ffmpeg and ImageMagick, so complete the task.  Let's go!

Use ffmpeg to Take Screenshots at Set Intervals

You have to view the ultimate task at hand in two steps:  create all the screenshots and then join them together.  ffmpeg is the best utility to take screenshots on intervals:

# Take a screencap every second
./ffmpeg -i jack-slow.mpeg -vf fps=1 video-caps/cap%d.png

# Take a screencap every minute
./ffmpeg -i jack-slow.mpeg -vf fps=1/60 video-caps/cap%03d.png

# Take a screencap every ten minutes
./ffmpeg -i jack-slow.mpeg -vf fps=1/600 video-caps/cap%04d.png

Depending on the length of video, you'll want to use one of the preceding shell command formats.  You may want to do the math (in your head or programmatically) to check video length and create a given number of thumbnails, but creating individual screenshots is the first step.

Use ImageMagick to Merge Images

While ffmpeg is great for video manipulation, ImageMagick is its image counterpart.  Joining images into one is incredibly easy:

# Append images vertically "-append"
convert video-caps/*.png -append video-caps/all.png

# Append images horizontally "-append"
convert video-caps/*.png +append video-caps/all.png

I love that joining images horizontally or vertically is as simple as one character and that I can use a wildcard to set the source directory and images. Here is a source video and example output:





If you want to open the image in your default image viewer, try this:

# Open with the default app
open all.png

# Open with a specific app
open -a /Applications/ all.png

The above works well on Mac -- if you don't use a Mac...good luck, I'm you'll need to figure out what works best on your OS.

The only hard part of setting this up is installing ImageMagick and ffmpeg, and then figuring out your image intervals.  There are probably more presentable ways to create these thumbnails but that's surely more involved.  Happy screening!

Recent Features

  • By
    Create Namespaced Classes with MooTools

    MooTools has always gotten a bit of grief for not inherently using and standardizing namespaced-based JavaScript classes like the Dojo Toolkit does.  Many developers create their classes as globals which is generally frowned up.  I mostly disagree with that stance, but each to their own.  In any event...

  • By
    CSS vs. JS Animation: Which is Faster?

    How is it possible that JavaScript-based animation has secretly always been as fast — or faster — than CSS transitions? And, how is it possible that Adobe and Google consistently release media-rich mobile sites that rival the performance of native apps? This article serves as a point-by-point...

Incredible Demos

  • By
    Introducing MooTools NextPrev

    One thing I love doing is duplicating OS functionalities. One of the things your OS allows you to do easily is move from one item to another. Most of the time you're simply trying to get to the next or the previous item.

  • By
    Create a Sexy Persistent Header with Opacity Using MooTools or jQuery

    I've been working with the Magento eCommerce solution a lot lately and I've taken a liking to a technique they use with the top bar within their administrative control panel. When the user scrolls below a specified threshold, the top bar becomes attached to the...


    Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!