2013-02-27 44 views

Trả lời

17

Không chắc chắn nếu điều này trả lời câu hỏi của bạn nhưng bạn có thể chạy âm thanh của video thông qua biểu đồ nút API âm thanh web. Mã dưới đây có thể được chứng minh bằng cách thay đổi các tham số về độ lợi và bộ lọc. Tôi chỉ thử nghiệm điều này trên Chrome.

<!DOCTYPE html> 
<meta charset="UTF-8"> 
<title></title> 
<body> 

</body> 


<script> 

var video = document.createElement("video"); 
video.setAttribute("src", "ourMovie.mov"); 

video.controls = true; 
video.autoplay = true; 
document.body.appendChild(video); 

var context = new webkitAudioContext(); 
var gainNode = context.createGain(); 
gainNode.gain.value = 1;     // Change Gain Value to test 
filter = context.createBiquadFilter(); 
filter.type = 2;       // Change Filter type to test 
filter.frequency.value = 5040;   // Change frequency to test 

// Wait for window.onload to fire. See crbug.com/112368 
window.addEventListener('load', function(e) { 
    // Our <video> element will be the audio source. 
    var source = context.createMediaElementSource(video); 
    source.connect(gainNode); 
    gainNode.connect(filter); 
    filter.connect(context.destination); 

}, false); 


</script> 

Đoạn mã trên là một phiên bản sửa đổi của điều này: http://updates.html5rocks.com/2012/02/HTML5-audio-and-the-Web-Audio-API-are-BFFs

Tôi chỉ đơn giản là thay thế các yếu tố âm thanh với các yếu tố video.

+0

Không biết bạn có thể chạy mà trên các yếu tố video! Cảm ơn, đây là chính xác những gì tôi muốn! – jreptak

+0

bài viết hay, thực sự hữu ích! – ejectamenta

+0

'webkitAudioContext' không được chấp nhận. Thay vào đó, hãy sử dụng 'AudioContext'. –

0

Webm hoạt động như một nguồn âm thanh.

<audio controls="controls" class="full-width" preload="metadata"> 
 
    <source src="//rack.international/samples/sample.webm" type="audio/mpeg"> 
 
</audio>

<video src="https://rack.international/samples/sample.webm" controls> 
 
    <p>Your browser doesn't support HTML5 video. Here is a <a href="rabbit320.webm">link to the video</a> instead.</p> 
 
</video>

Các vấn đề liên quan