Iphone 导出比使用AVAssetExportSession生成的原始文件大的文件

Iphone 导出比使用AVAssetExportSession生成的原始文件大的文件,iphone,avaudiorecorder,avassetexportsession,avmutablecomposition,Iphone,Avaudiorecorder,Avassetexportsession,Avmutablecomposition,我正在开发一个iPhone应用程序,它记录了多个文件,然后我将这些文件合并成一个文件,最后我将该文件上传到服务器上。 我的经验是,如果我制作一个7分钟大小的文件,它的大小是0.85 MB,但是如果我制作两个3.5分钟大小的文件,然后将它们合并到一个文件中,它的大小是9.75 MB,这是非常大的,上传时间太长。 请告诉我处理这个问题的方法。 提前谢谢 ` `您确定您的7分钟0.85 mb文件没有损坏吗?似乎有点小,如果不是不可能…不,它没有损坏,上传文件后,我下载它,听它,它与我记录它一样。 AV

我正在开发一个iPhone应用程序,它记录了多个文件,然后我将这些文件合并成一个文件,最后我将该文件上传到服务器上。 我的经验是,如果我制作一个7分钟大小的文件,它的大小是0.85 MB,但是如果我制作两个3.5分钟大小的文件,然后将它们合并到一个文件中,它的大小是9.75 MB,这是非常大的,上传时间太长。 请告诉我处理这个问题的方法。 提前谢谢 `


`

您确定您的7分钟0.85 mb文件没有损坏吗?似乎有点小,如果不是不可能…不,它没有损坏,上传文件后,我下载它,听它,它与我记录它一样。
AVMutableComposition* composition = [[AVMutableComposition alloc] init];
    AVMutableCompositionTrack* audioTrack = [composition addMutableTrackWithMediaType:AVMediaTypeAudio
                                                                     preferredTrackID:kCMPersistentTrackID_Invalid];
    //  kCMPersistentTrackID_Invalid, kCMMediaType_Audio,
    NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentPath_ = [searchPaths objectAtIndex: 0];
    // RecorderFilePaths contain the path of recorded files
    if ([recordedFilePaths count]>0)
    {
        NSError* error = nil;
        AVURLAsset* masterAsset= nil;
        CMTime time = kCMTimeZero;

        NSURL *tempUrl =[recordedFilePaths objectAtIndex:1];
        time = CMTimeAdd(time, [masterAsset duration]);
        AVURLAsset *Asset = [AVURLAsset URLAssetWithURL:tempUrl options:nil];
        CMTimeRange timeRange  = CMTimeRangeMake(kCMTimeZero, Asset.duration);
        NSArray *ar = [Asset tracksWithMediaType:AVMediaTypeAudio];
        [audioTrack insertTimeRange:timeRange ofTrack:[ar objectAtIndex:0] atTime:kCMTimeZero error:&error];
        //kAudioFormatMPEG4AAC,   AVMediaTypeAudio
        tempUrl = [recordedFilePaths objectAtIndex:0];
        masterAsset = [AVURLAsset URLAssetWithURL:tempUrl options:nil];
        timeRange = CMTimeRangeMake(kCMTimeZero, masterAsset.duration);
        NSArray *tracktypes = [masterAsset tracksWithMediaType:AVMediaTypeAudio];
        [audioTrack insertTimeRange:timeRange ofTrack:[tracktypes objectAtIndex:0] atTime:kCMTimeZero error:&error];

        if (error)
        {
            NSLog(@"%@",error);
            return;
        }

        AVAssetExportSession* exportSession = [AVAssetExportSession
                                               exportSessionWithAsset:composition
                                               presetName:AVAssetExportPresetAppleM4A];
        //  AVAssetExportPresetPassthrough,,AVAssetExportPresetLowQuality
        if (nil == exportSession)
        {            
            return;
        }

        NSString *urlSt = [documentPath_ stringByAppendingPathComponent:[self dateString]];
        NSURL* combined = [[NSURL alloc] initFileURLWithPath:urlSt];

        exportSession.outputURL = combined;
        exportSession.outputFileType = AVFileTypeAppleM4A;
        //  AVFileTypeAIFF , AVFileTypeAIFC, AVFileTypeAIFC,
        [exportSession exportAsynchronouslyWithCompletionHandler:^(void){

            dispatch_async(dispatch_get_main_queue(), ^{
                switch (exportSession.status)
                {
                    case AVAssetExportSessionStatusFailed:
                        NSLog(@"Failed");
                        break;
                    case AVAssetExportSessionStatusCompleted:
                        NSLog(@"Completed");
                        break;
                    case AVAssetExportSessionStatusWaiting:
                        break;
                    default:
                        break;
                }

            });
        }];

        [recordedFilePaths addObject:combined];
}