我录制了一个音频文件AVAudioEngin
,格式为:
@{ AVSampleRateKey:@(44100.0),
AVNumberOfChannelsKey: @(1),
AVFormatIDKey: @(kAudioFormatMPEG4AAC), }
,
然后我用AVAudioPlayer
,
self.player = [[AVAudioPlayer alloc] initWithData:[NSData dataWithContentsOfFile:self.outFilePath] error:nil];
NSTimeInterval duration = _player.duration; // 409.73357109834228
AVURLAsset*audioAsset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:self.outFilePath] options:nil];
CMTime audioDuration = audioAsset.duration;
Float64 seconds = CMTimeGetSeconds(audioDuration); // 429.31374149659865
为什么duration
不等于seconds
?
我错过了一些要设置的属性AVAudioPlayer
吗?