Generating thumbnails/screenshots of a video is useful in many ways. Youtube and many other video sites use this to show a preview of the video as a small thumbnail. Google video captures a series of thumbnails from a video at various time intervals to show a better video preview.
There is a simple way to generate thumbnails in Linux using ffmpeg, a very very useful tool for processing videos. Let us generate a thumbnail for this video. Download the video and rename it to test.avi.
Then, run this command,
ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
This command generates a 320×240 sized PNG thumbnail at the 4th second in the video. The output looks like this.
![]()
If you do not have ffmpeg installed and are using Debian/Ubuntu, do,
sudo apt-get install ffmpeg
A series of thumbnails, at 4, 8, 12 and 16 seconds.
![]()
![]()
![]()
![]()
ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg ffmpeg -itsoffset -8 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg ffmpeg -itsoffset -12 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg ffmpeg -itsoffset -16 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
useful links
- Create a random thumbnail of a video file
- http://www.danielfischer.com/2007/06/27/how-to-use-ffmpeg-to-convert-video-via-ruby-on-rails/
Happy thumbnailing!
Tags: ffmpeg, linux, thumbnail, video















aris wrote,
how if my filename is with space instead?!
ex: my video.avi
thanks for reply
Link | April 13th, 2008 at 6:49 am
prashanthellina wrote,
Try enclosing the filename in double quotes like this –> “my video.avi”
Link | April 13th, 2008 at 7:42 am
aris wrote,
still no effect..
i trying to upload
$filePath = $uploadDir.$fileName;
ffmpeg -i “.$filePath.” -y -s 320×240 -ab 32000 -ar 22050 -g 160 -cmp 3 -subcmp 3 -mbd 2 -flags aic+cbp+mv0+mv4+trell “.$convPath
where $filePath is source path where files is already uploaded.
upload is successfull but when ffmpeg start to conversion i got no files at $convPath.but vice versa if i use filename with no spaces instead.
Link | April 13th, 2008 at 7:53 am
prashanthellina wrote,
The command you posted here is missing a ” at the end. When the command runs, does it throw any errors?
Link | April 13th, 2008 at 6:48 pm
mike wrote,
Using “-ss” rather than “-itsoffset” is considerably faster. e.g. ffmpeg -ss 12 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320×240 test.jpg
Link | May 20th, 2008 at 11:35 pm
prashanthellina wrote,
Thanks for the info, Mike.
Link | June 1st, 2008 at 10:34 pm
sagar wrote,
Hi, is there any possibility to create thumbnails in windows environment
Link | July 17th, 2008 at 10:24 am
prashanthellina wrote,
Sagar, I have not tried it, but I think ffmpeg can be compiled for windows.
Link | July 17th, 2008 at 8:43 pm
sagar wrote,
Thanks Prashanth Ellina…
Link | July 18th, 2008 at 9:39 am
Roger wrote,
if you canot instal ffmpeg on the server is there another option to generate thumbnails on linux
Link | October 13th, 2008 at 11:00 pm
jojo wrote,
@mike , Very useful command , thanks .
Link | November 23rd, 2008 at 10:52 pm
dong wrote,
It is not work on Linux
Link | December 12th, 2008 at 12:32 pm
dong wrote,
Help?? Please make it work on Linux
Link | December 12th, 2008 at 12:35 pm
Tech Musing on C&P » Blog Archive » Audio Stitching with ffmpeg wrote,
[…] Creating Video Thumbnails using FFmpeg (for -itsoffset) […]
Link | December 15th, 2008 at 7:32 am