You might want to look at AVAssetExportSession, which makes it reasonably simple to re-encode videos. I think it's also hardware-supported when possible like the rest of AVFoundation:
https://developer.apple.com/library/ios/#DOCUMENTATION/AudioVideo/Conceptual/AVFoundationPG/Articles/01_UsingAssets.html
Note that it will never make the video larger than it already is, so you aren't guaranteed to get the output size you request. The following code might be a start for what you want, assuming you have an instance of ALAsset:
- (void)transcodeLibraryVideo:(ALAsset *)libraryAsset
toURL:(NSURL *)fileURL
withQuality:(NSString *quality) {
// get a video asset for the original video file
AVAsset *asset = [AVAsset assetWithURL:
[NSURL URLWithString:
[NSString stringWithFormat:@"%@",
[[libraryAsset defaultRepresentation] url]]]];
// see if it's possible to export at the requested quality
NSArray *compatiblePresets = [AVAssetExportSession
exportPresetsCompatibleWithAsset:asset];
if ([compatiblePresets containsObject:quality]) {
// set up the export
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]
initWithAsset:asset presetName:quality];
exportSession.outputURL = fileURL;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
// run the export
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch ([exportSession status]) {
case AVAssetExportSessionStatusFailed:
//TODO: warn of failure
break;
case AVAssetExportSessionStatusCancelled:
//TODO: warn of cancellation
break;
default:
//TODO: do whatever is next
break;
}
[exportSession release];
}];
}
else {
//TODO: warn that the requested quality is not available
}
}
You would want to pass a quality of AVAssetExportPreset960x540 for 540p and AVAssetExportPreset1280x720 for 720p, for example.