objective-c - AVAssetExportSession - 仅 mov 音频文件导出失败?

标签 objective-c ios xcode4 avassetexportsession


我有一个可以播放多种音频格式的音频播放器。该应用程序正在使用 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];
}

最佳答案

对于音轨只有.mov文件,输出应该是

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

exportSession.outputURL=pathURL;
exportSession.outputFileType=AVFileTypeAppleM4A;

关于objective-c - AVAssetExportSession - 仅 mov 音频文件导出失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12836320/

相关文章:

objective-c - ProgressView 溢出 UIView 边界

objective-c - 如果可能的话,如何以编程方式将 iPhone 连接到外部设备和路由器,无论是 WiFi

xcode4 - 如何在 Xcode4 中的界面构建器停靠的大纲 View 中方便地显示/展开子级别

xcode4 - Restkit + MKStoreKit : duplicate symbol because of JSONKit

ios - 一台mac创建2个证书

xcode - 使用 ComponentsJoinedByString 打印数组 : method

objective-c - 无法将 Objective-C 代码导入 Swift 文件

ios - 在自定义框架中使用聚合目标

iphone - 如何将 UITextfield 输入与不同的字符串进行比较?

android - 作为 Web 服务的 SIP API