简体   繁体   English

如何在 javascript 中获取视频标签的音频 output 音量

[英]How to get the audio output volume of a video tag in javascript

I don't want to get the volume set by the user for the video, I want to get the total volume of the audio of a video.我不想获取用户为视频设置的音量,我想获取视频音频的总音量。 Can someone please tell me how to do this?.有人可以告诉我该怎么做吗? I want to do this because I want to highlight the video which has the highest audio output with a colored border.我想这样做是因为我想用彩色边框突出显示具有最高音频 output 的视频。

I think you mean you want to get the audio level of each video, similar to a VU meter for audio tracks or an indication in a video conference of who who is speaking loudest.我认为您的意思是您想要获取每个视频的音频电平,类似于音轨的 VU 表或视频会议中谁说话声音最大的指示。

If so then an AnalyserNode ( https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode ) is most likely that you want:如果是这样,那么您很可能需要一个 AnalyserNode ( https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode ):

[An AnalyserNode] is an AudioNode that passes the audio stream unchanged from the input to the output, but allows you to take the generated data, process it, and create audio visualizations. [An AnalyserNode] 是一个 AudioNode,它将音频 stream 从输入不变地传递到 output,但允许您获取生成的数据、处理它并创建音频可视化。

There is a good overview of how to use it here:这里有一个很好的概述如何使用它:

And a working demo, with the excellent name 'Voice-change-o-matic' - this uses the microphone as the audio source but you can modify this as needed:还有一个名为“Voice-change-o-matic”的工作演示 - 它使用麦克风作为音频源,但您可以根据需要对其进行修改:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM