Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios AVAssetExportSession fileLengthLimit被忽略,EstimatedOutpFileLength返回0_Ios_Avfoundation_Avassetexportsession - Fatal编程技术网

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]);