Click here to Skip to main content
15,896,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to extract a thumbnail image from a video file when i upload it using jquery. I tried below code but it gives a black image.

What I have tried:

document.getElementById("fld").addEventListener('change', function (e) {

url = window.URL.createObjectURL(e.target.files[0]);
var video = document.createElement('video');

video.src = url;

var canvas = document.createElement('canvas');
canvas.width = 360;
canvas.height = 240;
var context = canvas.getContext('2d');

context.drawImage(video, 0, 0, canvas.width, canvas.height);
var dataURI = canvas.toDataURL('image/jpeg');
$('#imgpath').attr('src',dataURI);

}, false);
Posted
Updated 8-May-17 1:44am

This is what you searching for:


[Video to image tumbnail]
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900