I think youtube has many people working for it so probably do it manually.
or
it isnt done using php and probably in asp (i dont no the exact code....oranything near) it probably gets the amount of frames the file has, gets the first frame gets the last frame and gets the centre frame and using gd or something like that turns it into a jpg/gif what ever it is.
basically ull probs have to find some sort of template on the internet. or find away of contacting youtube and asking them.