简体   繁体   English

AVAssetExportSession-仅mov音频文件无法导出?

[英]AVAssetExportSession - mov audio only file failed to export?


I have an audio player which should be able to play multiple audio formats. 我有一个音频播放器,应该可以播放多种音频格式。 The app is using the BASS audio library and it needs some exports. 该应用程序正在使用BASS音频库,并且需要一些导出。 Below are the formats. 以下是格式。 All are working fine, except for the files in .mov (audio only) format. 除了.mov(仅音频)格式的文件外,其他所有文件都工作正常。

Any ideea about the right approach to fix that? 关于解决此问题的正确方法有什么想法?


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];
}

for audio track only .mov file , the output should be 对于仅音频轨道.mov文件,输出应为

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM