ios - 如何找到两个音频文件的偏移量?一吵一清

标签 ios objective-c audio synchronization audio-comparison

我曾经有过这样的场景,用户用表演者的实时音频捕捉音乐会场景,同时设备从音频广播设备下载实时流媒体。后来我用我已经流式传输并保存在手机中的那个(优质音频)。现在我在合并时通过反复试验手动设置音频偏移,这样我就可以在准确的位置同步音频和视频事件。

现在我想做的是自动执行音频同步过程。我不想在给定的偏移量处将视频与清晰的音频合并,而是想通过适当的同步自动将视频与清晰的音频合并。

为此,我需要找到我应该用清晰的音频替换嘈杂音频的偏移量。例如当用户开始录制和停止录制时,我将获取实时音频样本并与实时流式传输音频进行比较,并从中获取该音频的确切部分并在完美的时间同步。

有没有人知道如何通过比较两个音频文件并与视频同步来找到偏移量?

最佳答案

这是一个简洁明了的答案。

• 这并不容易 - 它将涉及信号处理和数学。
• 快速谷歌给我 this解决方案,包括代码。
• 有关上述技术的更多信息 here .
• 我建议您在尝试将其移植到 iOS 之前至少获得基本的了解。
• 我建议您使用 Accelerate iOS 上用于快速傅里叶变换等的框架
• 我不同意关于在服务器上执行此操作的其他答案 - 现在的设备功能非常强大。用户不会介意处理几秒钟的时间来处理看似神奇的事情。

Edit

As an aside, I think it's worth taking a step back for a second. While math and fancy signal processing like this can give great results, and do some pretty magical stuff, there can be outlying cases where the algorithm falls apart (hopefully not often).

What if, instead of getting complicated with signal processing, there's another way? After some thought, there might be. If you meet all the following conditions:

• You are in control of the server component (audio broadcaster device)
• The broadcaster is aware of the 'real audio' recording latency
• The broadcaster and receiver are communicating in a way that allows accurate time synchronisation

...then the task of calculating audio offset becomes reasonably trivial. You could use NTP or some other more accurate time synchronisation method so that there is a global point of reference for time. Then, it is as simple as calculating the difference between audio stream time codes, where the time codes are based on the global reference time.

关于ios - 如何找到两个音频文件的偏移量?一吵一清,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41391913/

相关文章:

python - matplotlib- Y 轴和 X 轴交换

ios - Swift 中的 Webview 管理

iphone - 为什么我的表格 View 单元格在使用 reloadRowsAtIndexPaths 重新加载时消失?

objective-c - 在编译时 super 静态绑定(bind)?

iphone - 如何使用 Plist 中的标签添加动态创建的文本字段并获取值

actionscript-3 - 声音字节数组的AS3播放不是从一开始就开始

ios - 如何使用 traccar 开源跟踪移动位置?

ios - UIButton 图像只改变一个按钮

php - 从 iOS POST 到 MySQL 数据库

audio - 音频文件带宽限制