I have a video of 10 seconds which I would like to control using HTML5. There are 2 input fields for the user. One is start time (like 3 seconds) in first box and input duration to play (6 seconds) in second box. For example, they might want to start the video 3 seconds in and play for 6 seconds. How can I download that certain part of that video or show that part of video in another video element and download it?
I tried using playing video to canvas and downloading it but I failed. There is no information regarding playing video to another element.
I have tried to implement it with canvas drawImage() method but it does not display anything in canvas.
function extractFunction(){
video.addEventListener('timeupdate', function() {
if (video.currentTime >= endTime) {
this.pause;
}
}, false);
video.load();
video.play();
try {
video.currentTime = starttime;
ctx.drawImage($this, 0, 0);
setTimeout(loop, 1000 / 30); // drawing at 30fps
} catch (ex) {
}
}
In the above code I have a button which will trigger this function.
currentTimeproperty. You can use this property to begin drawing the video on the canvas from a certain moment. It can also be used to stop the video. - enxaneta