Home > DeveloperSection > Forums > How to set session AVAssetExportSession in ios?
marcel ethan
marcel ethan

Total Post:105

Points:735
Posted on    October-17-2014 11:58 PM

 iPhone iPhone  Ios 
Ratings:


 1 Reply(s)
 873  View(s)
Rate this:
NSArray *pres = [AVAssetExportSession exportPresetsCompatibleWithAsset:asset];
        if([pres containsObject:AVAssetExportPreset640x480]) {
            AVAssetExportSession *session = [[AVAssetExportSession alloc]initWithAsset:asset presetName:AVAssetExportPreset640x480];
            FileManagerUtilities *fUtil = [[FileManagerUtilities alloc]init];
            session.outputURL = [NSURL fileURLWithPath:[fUtil searchPathDirectory:NSDocumentDirectory byAppendingDirectoryPath:nil andFileName:@"tempVideo.mov"]];
            session.outputFileType = AVFileTypeQuickTimeMovie;
            session.fileLengthLimit = 10.0;
            [session exportAsynchronouslyWithCompletionHandler:^{

                switch ([session status]) {
                    case AVAssetExportSessionStatusFailed:
                        NSLog(@"Export failed: %@", [[session error] localizedDescription]);
                        break;
                    case AVAssetExportSessionStatusCancelled:
                        NSLog(@"Export canceled");
                        break;
                    default:
                        break;
                }
            }];
        }
I am trying to set session.fileLengthLimit to 10mb but don't know what mistake I am doing. Unable to limit the size to 10mb, how to set fileLengthLimit to 10mb.


Jayden Bell
Jayden Bell

Total Post:105

Points:739
Posted on    October-18-2014 12:05 AM


An AVAssetExportSession object transcodes the contents of an AVAsset source object to create an output of the form described by a specified export preset.

The fileLenghtLimit should be in bytes, ie:

session.fileLengthLimit = 10*1024*1024;


Modified On Mar-22-2016 01:26:37 AM

Don't want to miss updates? Please click the below button!

Follow MindStick