2013-07-08 1 views
5

HTML5 자바 스크립트의 비디오에서 오디오 트랙을 어떻게 추출 할 수 있습니까? 나는. 샘플 배열?HTML5의 비디오에서 오디오를 어떻게 추출 할 수 있습니까?

예를 들어 HTML5 Video API가 완전히 새롭습니다.

+0

자바 스크립트가 이러한 작업에 적합한 지 여부는 알 수 없습니다. 이 주제를 참조하십시오 : http://stackoverflow.com/questions/11182587/extract-audio-from-video-stream-using-javascript –

답변

7

Web Audio API 정확히 원하는 것입니다. 특히 에 MediaElementAudioSourceNode을 공급하려고합니다. 안타깝게도 Web Audio API는 Chrome (FF로 구현 됨), Chrome doesn't have full support for MediaElementAudioSourceNode yet까지만 구현됩니다.

var context = new webkitAudioContext(); 

// feed video into a MediaElementSourceNode, and feed that into AnalyserNode 
// due to a bug in Chrome, this must run after onload 
var videoElement = document.querySelector('myVideo'); 
var mediaSourceNode = context.createMediaElementSource(videoElement); 
var analyserNode = context.createAnalyser(); 
mediaSourceNode.connect(analyserNode); 
analyserNode.connect(context.destination); 

videoElement.play(); 

// run this part on loop to sample the current audio position 
sample = new Float32Array(analyser.frequencyBinCount); 
analyser.getFloatFrequencyData(sample); 
+0

대단히 감사드립니다. 바라기를 더 많은 브라우저가 곧이를 지원할 것입니다. – James

+0

우리는 다른 방향으로 갈 수 있을까요? 샘플과 영상물이 있으면 비디오를 만들 수 있습니까? – James

+0

@ 제임스 어쩌면? Audio API를 사용하면 샘플을 버퍼링하고 어떻게 든 다시 재생할 수 있지만 확실하지는 않습니다. 어쨌든 실제 비디오 * 파일 *을 만들 수 없지만 음소거 된 비디오를 오디오 재생과 동기화 할 수 있습니다. – apsillers