NSPredicate to exclude slow motion videos from PHFetchResults

NSString *predicateFormat = [NSString stringWithFormat: @"mediaSubtype = %zd", PHAssetMediaSubtypeVideoHighFrameRate]; NSPredicate *predicate = [NSPredicate predicateWithFormat: predicateFormat]; PHFetchOptions *fetchOptions = [PHFetchOptions new]; fetchOptions.predicate = predicate; PHFetchResult *userAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeSmartAlbumVideos options:fetchOptions]; 

This is my code for retrieving video excluding slow motion video. But I get the following error. It doesn’t work, even if I like it,

 PHFetchOptions *fetchOptions = [PHFetchOptions new]; fetchOptions.predicate = [NSPredicate predicateWithFormat:@"(mediaSubtype & %d) == 0", PHAssetMediaSubtypeVideoHighFrameRate]; 

Someone please help. Thanks in advance.

 Unsupported predicate in fetch options: mediaSubtype == 131072 
0
source share
3 answers

Try the following:

 fetchOptions.predicate = [NSPredicate predicateWithFormat:@"(mediaSubtype != %d)", PHAssetMediaSubtypeVideoHighFrameRate]; 
+1
source

To exclude the slow motion video, the only predicate that worked for me is the following:

 PHFetchOptions *options = [PHFetchOptions new]; // Disable slow motion videos options.predicate = [NSPredicate predicateWithFormat:@"NOT ((mediaSubtype & %d) != 0)", PHAssetMediaSubtypeVideoHighFrameRate]; 
+2
source

Swift 4

 let assetFetchOptions = PHFetchOptions() assetFetchOptions.predicate = NSPredicate(format: "NOT ((mediaSubtype & %d) != 0)", PHAssetMediaSubtype.videoHighFrameRate.rawValue) 
0
source

Source: https://habr.com/ru/post/1242402/


All Articles