window.URL = window.URL || window.webkitURL;
function getDuration(control) {
var video = foreachdata;
video.preload = 'metadata';
video.onloadedmetadata = function () {
window.URL.revokeObjectURL(video.src);
var videodyrat = video.duration;
}
video.src = URL.createObjectURL(control.files[0]);
}
video.onloadeddata = () => alert(video.duration);
<button onclick='console.log(video.duration)'> жми </button>