iosobjective-cphotosframeworkphfetchoptions

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 to fetch videos which excludes slow motion videos. But I'm getting following error.This doesn't work even if I do like this,

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

Somebody please help. Thanks in advance.

Unsupported predicate in fetch options: mediaSubtype == 131072

Solution

  • Try this:

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