AVAssetExportSession导出导出时间错误

时间:2016-04-22 14:14:28

标签: ios objective-c xcode core-audio avassetexportsession

我想剪裁并导出我的.caf文件 我的代码是:

CMTime startTime = CMTimeMakeWithSeconds(self.audioFile.totalDuration * self.startSelectionPositionValue, NSEC_PER_SEC);
    CMTime endTime = CMTimeMakeWithSeconds(self.audioFile.totalDuration * self.endSelectionPositionValue, NSEC_PER_SEC);
    float startTimeInSeconds = CMTimeGetSeconds(startTime);
    float endTimeInSeconds = CMTimeGetSeconds(endTime);
    CMTimeRange exportTimeRange = CMTimeRangeFromTimeToTime(startTime, endTime);
    float duration = CMTimeGetSeconds(exportTimeRange.duration);

例如。我想修剪0到15秒。 startTimeInSeconds打印0. endTimeInSeconds打印15. exportTimeRange.duration打印15.但结果我的文件长度为15.07。 出口商代码:

    AVAssetExportSession *exporter = [AVAssetExportSession exportSessionWithAsset:sampleAsset presetName:AVAssetExportPresetAppleM4A];
        exporter.outputFileType = AVFileTypeAppleM4A;
        exporter.outputURL = exportUrl;
        exporter.timeRange = exportTimeRange;
        exporter.audioMix = audioMix;
[exporter exportAsynchronouslyWithCompletionHandler:^(void) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [MBProgressHUD hideHUDForView:self.view animated:NO];
            switch (exporter.status) {
                case AVAssetExportSessionStatusCompleted: {
                    // My completion code is there
                    break;
                }
                default:
                    break;
            }
        });
    }];

提前致谢:)

0 个答案:

没有答案