计算音频长度

// 耗时操作, 在主线程

AVURLAsset *avUrl = [AVURLAsset assetWithURL:[NSURL URLWithString:bodiesModel.url]];

CMTime time = [avUrl duration];

int seconds = ceil(time.value/time.timescale);

在工程中连接CoreMedia和AVFoundation框架

你可能感兴趣的:(计算音频长度)