FFMpeg - Creating Thumbnail for Video file

user1006460 picture user1006460 · Feb 1, 2012 · Viewed 28k times · Source

I am new to php. I have installed ffmpeg in my local iis.. Is it possible to generate a thumbnail image for a flv file.? Please help..

Answer

ravi404 picture ravi404 · Feb 3, 2012

Try this

$ffmpeg = 'ffmpeg.exe';

//video dir
$video = 'video.flv';

//where to save the image
$image = 'image.jpg';

//time to take screenshot at
$interval = 5;

//screenshot size
$size = '320x240';

//ffmpeg command
$cmd = "$ffmpeg -i $video -deinterlace -an -ss $interval -f mjpeg -t 1 -r 1 -y -s $size $image 2>&1";       
$return = `$cmd`;

An explanation of the command options:

-i filename (the source video's file path)
-deinterlace (converts interlaced video to non-interlaced form)
-an (audio recording is disabled; we don't need it for thumbnails)
-ss position (input video is decoded and dumped until the timestamp reaches position, our thumbnail's position in seconds)
-f output file format
-t duration (the output file stops writing after duration seconds)
-r fps (sets the frame rate to write at; fps is expressed in Hertz (1/seconds); we use 1 so that we grab only one frame)
-y (overwrites the output file if it already exists)
-s widthxheight (size of the frame in pixels)