ffmpeg get video thumbs through php

this script depends on the following packages and operating systems

Ubuntu 8.10 or server editions

convertToFlv( "some-video-input.avi", "output.jpg" );

function convertToFlv( $input, $output ) {
   echo "Converting $input to $output<br />";
   $command = "ffmpeg -v 0 -y -i $input -vframes 1 -ss 5 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 $output ";
   echo "$command<br />";
   shell_exec( $command );
   echo "Converted<br />";


lets get video thumbs from any video input within script

Line 2, is where you input your video is, this script must be on the same directory as your videos. please note that this script only seems to work on your /var/www official server directory. within a sub-folder it will not execute the script. not sure why that is.

alright lets move on, line 6 , is where the ffmpeg command is doing its thumbnail grabbing. the most important part about this command is the - SS this tells the command in which second should I grab thumbnail from this video ? - ss 5 stands for = 5 seconds into video get me thumbnail. so you get the idea, videos with 10 seconds or 5 seconds will not give you a thumbnail, so please do not try this with a very short video clip, its best that video has at least 40 seconds of playtime. you can of course change - SS to 1 but not worth you will just get mostly a black thumbnail as most videos start with something dark.

you can change this into something else which suits your needs, 286x160 this is thumbnail size i normally hate small thumbs thats why its so big. anyways, this part -aspect 16:9 should not be changed into 4:3 this will give your thumbs a box type of thumb which i honestly believe is the end of the world ! i hate box thumbs, i would like to see every video site have wide screen thumbs ! so don't make me angry lolz.

thats about it, i hope in few months ill be able to learn more about php and MySql, i will be using these scripts to combine them with vlc web plugin. something similar to stage6.com .


Posted on 19.12.2009 19:47

this not work :(, i'm using xampp on ubuntu 9.10 i install ffmgeg using synaptic package manager, do u have any idea about that.

Posted on 17.12.2009 19:37

this code is not work. is there any path set for ffmpeg

Posted on 09.05.2009 22:29

forgot to mention that this script gets JPG image thumbnail

Add your comment