Generating a thumbnail image with FFMPEG
Posted on | January 20, 2012 | 1 Comment
If you would like to know how to compress a video for the iPhone or how to quickly use FFMPEG-PHP use this guide: CONVERT VIDEO TO IPHONE FRIENDLY H264 WITH FFMPEG
/usr/bin/ffmpeg -y -itsoffset -6 -i "/var/www/html/myvideo.mpg" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 "/var/www/html/mypic.jpg";
The above will generate a JPEG (Joint Photographic Experts Group) with a MIME type of image/jpeg thumbnail for myvideo.mpg then store it at the assigned location (/var/www/html/mypic.jpg). Once your thumbnail has been generated you can use it in anything that supports the image type; web development, desktop application, etc.
FFMPEG options:
-y overwrite file if exists
-itsoffset the time offset in seconds (6 for this example. Great feature if you have many videos that start fading from black.)
-i input file (/var/www/html/myvideo.mpg) Double quotes are not needed but suggested if you are linking to a file-name with spaces in it.
-vcodec video codec settings (currently mjpeg for the Motion JPEG codec)
-vframes number of frames to capture (currently 1)
-an tells ffmpeg not to capture audio
-f force input (currently rawvideo)
-s frame size (currently 320×240)
Then finally the output file location. (/var/www/html/mypic.jpg)
All available frame sizes can be viewed within the FFMPEG documentation.
Comments
One Response to “Generating a thumbnail image with FFMPEG”
Leave a Reply


January 24th, 2012 @ 8:01 pm
[...] Before you can begin you will have to install FFMPEG. This guide covers some other uses and links to an install guide for the CENTOS Red Hat based operati… [...]