DIY - Generate Video Thumbnails
2 min read editmentary video · post-production · ffmpegThis 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
- Download and install FFMPEG, if you don’t have it already.
- 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) = 1⁄300
How often to thumbnail? | fps |
---|---|
every second | 1 |
every other second | 1⁄2 |
every minute | 1⁄60 |
every 5 minutes | 1⁄300 |
every 15 minutes | 1⁄600 |
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
- FFMPEG How To
- Wikipedia
- Stack Overflow FFMPEG Formats
- Sample MP4 for testing TODO Get open content for this before go-live
- JW Player Support
comments powered by Disqus