Я перекодирую видео с помощью 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;
}
}];
}
однако оцениваемыйOutputFileLength всегда возвращает 0, а fileLengthLimit, похоже, полностью игнорируется. Я хотел использовать предполагаемыйOutputFileLength, чтобы определить, следует ли использовать кодирование среднего или низкого качества.
Может ли это быть ошибкой iOS? Кто-нибудь заставил эти 2 свойства работать?