Ordinarily, you can get at the audio samples of an AVPlayer by using an MTAudioProcessingTap on the player item, however your asset resists this through AVURLAsset上的tracks属性从不可用当您观察并将水龙头连接到playerItem.tracks的assetTrack时,请不要回电.the tracks property on your AVURLAsset never becoming availablenot calling you back when you observe and attach the tap to your playerItem.tracks's assetTrack.我从未见过很好的解释,为什么它不适用于远程mp3或m3u8流,但令人讨厌的是,它确实适用于其他远程资产类型,例如aac.不公平地,在视频方面, AVPlayerItemVideoOutput 似乎适用于所有类型的资产(除非存在DRM问题)!I've never seen a good explanation for why this doesn't work for remote mp3s or m3u8 streams, and annoyingly, it does work for other remote asset types, like aac. Unjustly, on the video side, AVPlayerItemVideoOutput seems to work for all types of assets (barring DRM problems)!那么这会让你离开哪里?一种方法是自己流式传输mp3数据,您可以在其中使用AudioQueue对其进行解码和播放,然后 使用上述MTAudioProcessingTap计算峰值功率.还想到了涉及AudioConverter/AudioUnit和AVAudioConverter/AVAudioEngine的解决方案.So where does this leave you? One way is to stream the mp3 data yourself from where you can decode and play it using an AudioQueue, and also calculate the peak power using the aforementioned MTAudioProcessingTap. Solutions involving AudioConverter/AudioUnit and AVAudioConverter/AVAudioEngine come to mind too.如果只是为了替换单个属性而听起来工作量太大,则可以查看预先烘焙的解决方案,例如 StreamingKit 或 FreeStreamer ,然后计算功效.您可能会找到一个可以为您计算功率的库.如果没有,您可以使用此公式If that sounds like too much work just to replace a single property, you could look at pre-baked solutions, like StreamingKit or FreeStreamer and then calculate power. You may find a library that calculates power for you. If not, you can calculate peakPowerForChannel using this formula 这篇关于AVPlayer实时流如何获得功率以进行音频电平计量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-20 01:48