Generate Thumbnail Image from Video in PHP

Let’s see how to generate a thumbnail image from video.

First display Video that you uploaded on server. And after that do some JavaScript stuffs for generate image.

Here window load JavaScript event will run and generate the image as we pass the co-ordinates to that.

With this you have the Output as following:

thumbnail image

After this HTML stuff you have to do some AJAX/PHP call whatever you want. Here I have done the AJAX call:

Here we get the <canvas> value and pass it to the AJAX url.

Now in AJAX call we have to upload the image on server that we generate in <canvas>

Here we get the value from <canvas> is in the string format so transfer it to image like this:

For put it into server  give some image name and put with this:

And now let’s see our image:

thumbnail image

Now you have to display this image instead of Video to anywhere in the site.

  • Sameer Anwar

    I want the similar thing to happen except that it should happen when user selects a different video via file browse. I tired your code it does work as it it but when i tried to incporate it in File onChnage method it does not create any thumbnail. Can u suggest what change can be done?