2014-11-23 4 views
0

내가 선택한 동영상을 내보내는 데 AVAssetExportSession을 사용하고 있습니다. 내 보낸 영화가 실제로 취하는 바이트 수는 어떻게 얻습니까?내 보낸 영화가 iOS에서 사용하는 메모리 크기를 찾는 방법은 무엇입니까?

이것은 내 코드의 스 니펫입니다. 내가 알기로 : "exportSession.estimatedOutputFileLength",하지만 0 만 제공합니다. 또한 정확한 크기와 예상치가 필요하지 않으므로 제대로 작동한다고해도 올바른 방법이라고 확신하지 못합니다.

if ([compatiblePresets containsObject:AVAssetExportPresetLowQuality]) 
{ 
    AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]initWithAsset:avAsset presetName:AVAssetExportPresetPassthrough]; 
    NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString* docsDir = [paths objectAtIndex:0]; 
    NSString* targetFileName = [[mediaPath.description lastPathComponent] stringByDeletingPathExtension]; 
    NSString* formattedFileName = [NSString stringWithFormat:@"%@.mp4", targetFileName]; 
    NSString* videoPath = [NSString stringWithFormat:@"%@/%@", docsDir, formattedFileName]; 
    exportSession.outputURL = [NSURL fileURLWithPath:videoPath]; 
    exportSession.outputFileType = AVFileTypeMPEG4; 
    exportSession.shouldOptimizeForNetworkUse = NO; 

    NSLog(@"file size = %lld", exportSession.estimatedOutputFileLength);} 
+0

이 작업을 수행하는 방법 : NSData * videoData = [NSData dataWithContentsOfURL : exportSession.outputURL]; float movieSizeInKiloBytes = (float) [videoData length]/1024.0f; 내가 필요한 것을 제공합니까? 정확합니까? – gStation

답변

0

당신이 아래 참조

CMTime full = CMTimeMultiplyByFloat64(exportSession.asset.duration, 1); 
exportSession.timeRange = CMTimeRangeMake(kCMTimeZero, full); 

내보낼 의도 미디어의 범위를 제공하는 데 필요한 estimatedOutputFileLength 전에 추가 시도 또한 수 없습니다 사용 AVAssetExportPresetPassthrough

이후

/* 내 보낸 파일의 예상 바이트 크기를 나타냅니다. 내보내기 사전 설정이 AVAssetExportPresetPassthrough 또는 AVAssetExportPresetAppleProRes422LPCM 일 때 0을 반환합니다. timeRange 속성에 대한 숫자 값 (즉, 유효하지 않은 값, 무제한 값 또는 무한 값)이 설정되지 않은 경우이 속성도 0을 반환합니다. */