HOW TO SET SESSION AVASSETEXPORTSESSION IN IOS?

marcel ethan

Total Post:105

Points:735
Posted by  marcel ethan
iPhone  Ios 
 1218  View(s)
Ratings:
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.
  1. Jayden Bell

    Post:110

    Points:774
    Re: How to set session AVAssetExportSession in ios?


    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!