4

estimatedOutputFileLengthのプロパティがAVAssetExportSession常に0を返す (シミュレータでは-9223372036854775808を返す)問題があります。

私はこれを機能させるためにあらゆることを試しました。さまざまなoutputFileTypes を試し、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);

これが機能しない理由がわかりません!(iOS6、iPhone5)

4

2 に答える 2

1

時間範囲を含める必要があります。

エクスポートするファイルの量。それがなければ、0 を返します。

AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset: songAsset presetName: AVAssetExportPresetAppleM4A];
exporter.outputFileType = AVFileTypeAppleM4A;

CMTime full = CMTimeMultiplyByFloat64(exporter.asset.duration, 1);
exporter.timeRange = CMTimeRangeMake(kCMTimeZero, full);
long long size = exporter.estimatedOutputFileLength;
fileInfo.fileSize = size;
于 2014-10-28T11:08:59.850 に答える