AVAssetExportSession
的 estimatedOutputFileLength
属性总是返回 0(并返回 -9223372036854775808模拟器)。
我已尽一切努力让它工作,尝试不同的 outputFileType
,打开和关闭 shouldOptimizeForNetworkUse
,指定(或不指定)outputURL
...尽管如此,似乎没有任何效果,我开始认为这可能是 SDK 中的错误。
这是我的代码:
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetMediumQuality]; // doesn't matter which preset is used
//exportSession.shouldOptimizeForNetworkUse = YES;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
NSLog(@"bytes = %lld", exportSession.estimatedOutputFileLength);
我只是想不通为什么这不起作用! (iOS 6, iPhone 5)
最佳答案
您可以通过在 exportSession 上设置适当的 timeRange 来解决此问题:
exportSession.timeRange = CMTimeRangeMake(kCMTimeZero, asset.duration);
似乎在 iOS 中,AVAssetExportSessionInternal.timeRange 在估计文件长度时没有得到合理的结果。
关于iphone - AVAssetExportSession estimatedOutputFileLength 总是返回 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14328576/