Ios AVAssetExportSession fileLengthLimit被忽略,EstimatedOutpFileLength返回0
我正在使用Ios AVAssetExportSession fileLengthLimit被忽略,EstimatedOutpFileLength返回0,ios,avfoundation,avassetexportsession,Ios,Avfoundation,Avassetexportsession,我正在使用AVAssetExportSession重新编码视频,我想尝试将生成的文件大小保持在限制以下。我最后的电话是这样的: NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:avAsset]; if ([compatiblePresets containsObject:AVAssetExportPresetMediumQuality])
AVAssetExportSession
重新编码视频,我想尝试将生成的文件大小保持在限制以下。我最后的电话是这样的:
NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:avAsset];
if ([compatiblePresets containsObject:AVAssetExportPresetMediumQuality])
{
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]initWithAsset:mixComposition presetName:AVAssetExportPresetMediumQuality];
exportSession.outputURL = outputURL;
exportSession.fileLengthLimit = 600000;
exportSession.outputFileType = AVFileTypeMPEG4;
exportSession.shouldOptimizeForNetworkUse = YES;
exportSession.videoComposition = mainCompositionInst;
NSLog(@"bytes = %lli", exportSession.estimatedOutputFileLength);
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch ([exportSession status])
{
case AVAssetExportSessionStatusFailed:
NSLog(@"Export failed: %@ : %@", [[exportSession error] localizedDescription], [exportSession error]);
handler(nil);
break;
case AVAssetExportSessionStatusCancelled:
NSLog(@"Export canceled");
handler(nil);
break;
default:
handler(outputURL);
break;
}
}];
}
但是,EstimatedOutFileLength始终返回0,并且fileLengthLimit似乎被完全忽略。我想使用EstimatedOutpFileLength来确定是使用中等质量编码还是低质量编码
这可能是一个iOS错误吗?有人使用了这两个属性吗?为后代添加了一个注释,关于ExstimatedOutFileLength始终返回0,我必须向导出会话添加一个时间范围
exportSession.timeRange = CMTimeRangeMake(kCMTimeZero, [asset duration]);