2014-12-18 2 views

답변

10

어때?

// create the video element but don't add it to the page 
 
var vid = document.createElement('video'); 
 
document.querySelector('#input').addEventListener('change', function() { 
 
    // create url to use as the src of the video 
 
    var fileURL = URL.createObjectURL(this.files[0]); 
 
    vid.src = fileURL; 
 
    // wait for duration to change from NaN to the actual duration 
 
    vid.ondurationchange = function() { 
 
    alert(this.duration); 
 
    }; 
 
});
<input type="file" id="input">

+1

이 체크 아웃 - 적어도 나는 그것을 시도 십초 비디오가 다시 10.12 결과왔다. 맵시 있는! –

-4

비디오 파일은 기간을 결정하기 위해 실제 플레이어가 디코딩해야합니다. JavaScript는 바이트 수만 계산할 수 있습니다.

관련 문제