I'm trying to take a screenshot of video with predefined time in the movie. So I tried it with the canvas element. The thing is that the video must be playing when you draw the image of the video, but I need the image to still be paused. So I tried this:
video.play();
context.drawImage(video,0,0,canvas.width,canvas.height);
video.pause();
But as you probably can imagine, the video pauses before the canvas is done drawing, resulting in no screenshot. So is there a callback function for drawImage? In my case, the drawing process takes about 50ms, but it doesn't feel safe to do:
setTimeout(function() { video.pause(); }, 50);
Windows + PrtScn: To a screenshot of your video in the full-screen mode. Hit the hotkeys after pausing your video, and the screen will briefly go dim to indicate that you have taken a screenshot. Your screenshots will be saved in the Screenshots folder inside the Pictures folder.
HTML5 is the latest version of HTML. Unlike previous versions of HTML, HTML5 enables developers to easily add video to webpages with a video tag.
The HTML5 “video” element specifies a standard way to embed a video on a web page. There are three different formats that are commonly supported by web browsers – mp4, Ogg, and WebM.
Rather than pausing you could try setting the video's playbackrate to something very low (or zero if that works?):
video.playbackRate = 0.0001; // or 0
This will effectively pause the video for you.
You could also set the canvas to black, tranparency 0.99 and then scan the resulting image in your timeout for a non-black pixel:
setTimeout(function() {
pixel = context.getImageData(image.width/2, image.height/2, 1, 1);
// do something with the pixel, kick off another timeout if it is still has transparency
}, 50);
When using the last method the video must be from the same domain as the script, and will not work on local files because of security constraints.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With