2


我有一个音频播放器,它应该能够播放多种音频格式。该应用程序正在使用 BASS 音频库,它需要一些导出。以下是格式。除了 .mov (仅限音频)格式的文件外,一切都运行良好。

关于解决这个问题的正确方法有什么想法吗?


exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetPassthrough];
if (nil == exportSession)
    @throw [NSException exceptionWithName:TSUnknownError reason:@"Couldn't create AVAssetExportSession" userInfo:nil];

if ([[assetURL pathExtension] compare:@"mp3"] == NSOrderedSame) {
    [self doMp3ImportToFile:destURL completionBlock:completionBlock];
    return;
}

exportSession.outputURL = destURL;

// set the output file type appropriately based on asset URL extension
if ([[assetURL pathExtension] compare:@"m4a"] == NSOrderedSame) {
    exportSession.outputFileType = AVFileTypeAppleM4A;
} else if ([[assetURL pathExtension] compare:@"wav"] == NSOrderedSame) {
    exportSession.outputFileType = AVFileTypeWAVE;
} else if ([[assetURL pathExtension] compare:@"aif"] == NSOrderedSame) {
    exportSession.outputFileType = AVFileTypeAIFF;
} else if ([[assetURL pathExtension] compare:@"mp4"] == NSOrderedSame) {
    exportSession.outputFileType = AVFileTypeMPEG4;
} else if ([[assetURL pathExtension] compare:@"mov"] == NSOrderedSame) {
    exportSession.outputFileType = AVFileTypeQuickTimeMovie;
} else {
    @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"unrecognized file extension" userInfo:nil];
}
4

1 回答 1

6

仅对于音轨 .mov 文件,输出应为

AVAssetExportSession *exportSession=[AVAssetExportSession exportSessionWithAsset:asset presetName:AVAssetExportPresetAppleM4A];

exportSession.outputURL=pathURL;
exportSession.outputFileType=AVFileTypeAppleM4A;
于 2012-11-17T02:38:26.573 回答