简体   繁体   English

Swift - 如何使用AVFoundation录制音频时消除延迟

[英]Swift - How to remove delay when recording audio using AVFoundation

I'm using an app that records audio and streams it to another user. 我正在使用一个记录音频的应用程序并将其流式传输给另一个用户。 It's basically a VoIP call. 它基本上是一个VoIP通话。 The problem I'm running into is that the audio I'm streaming to the peer is delayed by about 0.5 seconds. 我遇到的问题是我流向对等端的音频延迟了大约0.5秒。 This is quite noticeable, and a little annoying when you both try to talk at the same time. 这是非常明显的,当你们两个试图同时说话时有点烦人。

I'm wondering if this is common among AVFoundation's AVAudioEngine, or if possibly it's something to do with the way I set it up. 我想知道这在AVFoundation的AVAudioEngine中是否很常见,或者是否可能与我设置它的方式有关。

I can include source code if this is NOT a known problem with AVAudioEngine, otherwise can you please suggest the best route to record audio with the least delay? 如果这不是AVAudioEngine的已知问题,我可以包含源代码,否则你能建议最短路径来录制音频吗?

I would also prefer something that is fairly high-level, and compatible with swift 3/3.1. 我也喜欢相当高级的东西,并且与swift 3 / 3.1兼容。 However, if there is not a solution that meets these needs, then recommend the tool you think seems best fit. 但是,如果没有满足这些需求的解决方案,那么推荐您认为最适合的工具。

Thank you! 谢谢!

确保使用最小支持的bufferSize(100 ms)或(sampleRate * 0.1)样本调用“AVAudioEngine.inputNode.installTap”函数。

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

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