DIY - Generate Video Thumbnails

      2 min read           · ·

This quick and dirty DIY will tell you how to generate a thumbnail based on content in your videos. Without having to grab stills from your favorite ILE. All for the low, low price of Free.99.

Before you get started

  1. Download and install FFMPEG, if you don’t have it already.
  2. Have a video on your computer or accessible online.

Grab a number every second

ffmpeg -i input.flv -vf fps=1 out%d.jpg

will out put a JPG file every 1 second of video. Want a JPG file for every other second? Too easy.

ffmpeg -i input.flv -vf fps=1/2 out%d.jpg

Notice, that the only change between the two is that fps=1 changed to

every 2 seconds

How about 1 JPG for every 1 minute of video?

``` shell
ffmpeg -i input.flv -vf fps=1/60 out%d.jpg

Wait! Wha?!? Where did the 60 come from?

There are 60 seconds per minute. So to get a thumbnail every minute, then 1 over the number of seconds that you are seeking a thumbnail. So, if you want a thumbnail every 5 minutes, 1/ (60*5) = 1300

How often to thumbnail?fps
every second1
every other second12
every minute160
every 5 minutes1300
every 15 minutes1600

Grab a thumbnail from a specific time in the video

ffmpeg -i input.mp4 -ss 00:00:14.435 -vframes 1 out.jpg

Grabbing a video every second, or every 100 seconds, or from a specified time in the video can lead to mixed results. Sometimes, the thumbnails are clear and crisp, assuming the video is clear and crisp. other times, the thumbnails appear slightly blurred, even though the overall video is crisp. To solve this, Grab thumbnails based on the video’s i-frame.

ffmpeg -i input.flv -vf "select='eq(pict_type,PICT_TYPE_I)'" -vsync vfr out.jpg

Grab a thumbnail every X-number-of Frames…

ffmpeg -i somemovie.mp4 -vf ‘thumbnail=TAKE_ONE_OF_EVERY_X_FRAMES,scale=80:45,tile=5x8:nb_frames=40:padding=0:margin=0’ -an -vsync 0 overview.jpg

TAKE_ONE_OF_EVERY_X_FRAMES is the tricky number, that you will have to calculate based on the framerate and length of your inputfile. If the number is not right, you end with more then one sprite image.

Resources

  1. FFMPEG How To
  2. Wikipedia
  3. Stack Overflow FFMPEG Formats
  4. Sample MP4 for testing TODO Get open content for this before go-live
  5. JW Player Support

Disagree? Did I miss something? Comment below .
comments powered by Disqus