In my app i create a movie file from an array of still images using AVAssetWriter, AVAssetWriterInput and AVAssetWriterInputPixelBufferAdaptor (There are a lot of threads describing how to do that). As the AVAssetWriterInput output settings AVVideoWidthKey and AVVideoHeightKey, i let the user choose a video resolution (1080p, 720p, 540p or 480p) which i then also use for the -pixelBufferFromCGImage: method.
Creating a video works well with all resolutions on my iPhone 5. However on my iPhone 3GS every resolution higher than 480p gives me no video output but i also get no error except when i use 1080p as resolution (in this case, the -pixelBufferFromCGImage: method returns NULL). It is ok to me that the 3Gs might never be able to export videos with higher resolution than 480p as well as the iPhone 4 might not be able to export 1080p videos.
However, my question is: how would i check which video resolutions the device can write and only offer these resolutions to the user?
Digging into the AVFoundation i found the solution by myself. I just had to check the AVAssetExportSessions allExportPresets property for the presets i would want to use even if i don't use the presets themselfs rather than creating my own options.
To do this, i use this code:
if([[AVAssetExportSession allExportPresets] containsObject:AVAssetExportPreset640x480]){
NSLog(@"480p");
}
if([[AVAssetExportSession allExportPresets] containsObject:AVAssetExportPreset960x540]){
NSLog(@"540p");
}
if([[AVAssetExportSession allExportPresets] containsObject:AVAssetExportPreset1280x720]){
NSLog(@"720p");
}
if([[AVAssetExportSession allExportPresets] containsObject:AVAssetExportPreset1920x1080]){
NSLog(@"1080p");
}