+ exportSessionWithAsset:presetName:在iOS7上返回nil

时间:2015-06-06 04:44:57

标签: ios objective-c cocoa ios7 avmutablecomposition

我正在使用以下代码:

Uh oh, something went wrong (Code: 141, Version: 1.7.2)

这可以在iOS8上实现,但在iOS7上,exportSession在方法结束时总是为零。我尝试使用不同格式的资源(mp3,caf)但结果是一样的。

如果我播放合成而不是导出它,声音很好:

- (AVAssetExportSession *)testRecording
{
    AVMutableComposition *composition = [[AVMutableComposition alloc] init];

    NSURL *url = [[NSBundle mainBundle] URLForResource:kTestSongName withExtension:@"mp3"];
    AVAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
    CMTimeRange range = CMTimeRangeMake(CMTimeMake(0, 600), asset.duration);
    NSError *editError;

    BOOL result = [composition insertTimeRange:range ofAsset:asset atTime:kCMTimeZero error:&editError];
    if (!result) {
        NSLog(@"Error inserting timerange");
    }
    AVAssetExportSession *exportSession = [AVAssetExportSession
                                           exportSessionWithAsset:composition
                                           presetName:AVAssetExportPresetAppleM4A];
    return exportSession;

}

有什么可能出错的想法吗?

1 个答案:

答案 0 :(得分:0)

library(stringi)
library(data.table)
Count <- stri_count_fixed(d$list,", ")+1
d2 <- strsplit(d$list, split = ", ")
d2 <- lapply(d2, function(x) as.data.frame(t(combn(x, m=2))))
rbindlist(Map(cbind, d2, Count=Count))
#      V1    V2 Count
# 1:   SD1  SD44     4
# 2:   SD1 SD384     4
# 3:   SD1  SD32     4
# 4:  SD44 SD384     4
# 5:  SD44  SD32     4
# 6: SD384  SD32     4
# 7:  SD23   SD1     3
# 8:  SD23 SD567     3
# 9:   SD1 SD567     3
#10:  SD42 SD345     3
#11:  SD42 SD183     3
#12: SD345 SD183     3
#13: SD345 SD340     3
#14: SD345 SD387     3
#15: SD340 SD387     3
#16: SD455  SD86     3
#17: SD455  SD39     3
#18:  SD86  SD39     3
#19:  SD12 SD315     3
#20:  SD12 SD387     3
#21: SD315 SD387     3
#22:  SD32   SD1     3
#23:  SD32  SD40     3
#24:   SD1  SD40     3

如果您想以mp3格式保存,请使用ffmpeg