-3

I want to create a thumbnail from a video so it can be uploaded alongside the video itself to a server. I have tried searching for js libs to do the work but cant seem to find any that is simple enough.

The user would be selecting the video from a and want to be able to create a thumbnail from it and finally uploaded both the video and thumbnail to a server.

Do you know any js libs or anyway it could be done ?

marvin ralph
  • 1,100
  • 3
  • 23
  • 43

1 Answers1

4

Using Canvas you can capture the video Thumb. here is the working example.

function thumbnail(){
    var canvas = document.getElementById('canvas');
    var video = document.getElementById('video');
    canvas.getContext('2d').drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
}
document.getElementById('capture').addEventListener('click', function(){
 thumbnail(); 
});
<button id="capture">
  capture
</button>
<canvas id="canvas"></canvas>
<video width="320" height="240" id="video" controls>
   <source src=http://techslides.com/demos/sample-videos/small.ogv type=video/ogg> 
  <source src=http://techslides.com/demos/sample-videos/small.mp4 type=video/mp4>
Your browser does not support the video tag.
</video>
Abid Nawaz
  • 866
  • 6
  • 20