Domanda


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. Below are the formats. All are working fine, except for the files in .mov (audio only) format.

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];
}
È stato utile?

Soluzione

for audio track only .mov file , the output should be

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

exportSession.outputURL=pathURL;
exportSession.outputFileType=AVFileTypeAppleM4A;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top