No slow motion effect in exported from camera roll video on iPhone 6/6+

978 views Asked by At

I'm developing app that works with video. It makes short movies from recorded or exported from camera roll videos. I need help with some unexpected behavior.

When I export video recorded with apple slow motion effect - such effect is lost in video in my app.

This's reproduced on iPhone 6 and 6+ and I assume on iPhone 5s too. On iPhone 5s/6/6+ Simulator, everything is ok. To export video I use iOS SDK ALAssetsLibrary API, code:

NSMutableArray* allVideos = [[NSMutableArray alloc] init];
self.assetLibrary = [[ALAssetsLibrary alloc] init];

[self.assetLibrary enumerateGroupsWithTypes: ALAssetsGroupAll
                                 usingBlock: ^(ALAssetsGroup* group, BOOL* stop1){

                                     if (group) {
                                         [group setAssetsFilter: [ALAssetsFilter allVideos]];
                                         [group enumerateAssetsUsingBlock: ^(ALAsset* asset, NSUInteger index, BOOL* stop2){

                                             if (asset) {
                                                [allVideos addObject: asset];
                                             }
                                         }];
                                     }
                                     else {
                                         //sort by last shooted video
                                         self.view.videoAssetRepresentations = [allVideos sortedArrayUsingComparator: ^NSComparisonResult (ALAsset* obj1, ALAsset* obj2) {
                                             return [[obj1 valueForProperty: ALAssetPropertyDate] timeIntervalSince1970] < [[obj2 valueForProperty: ALAssetPropertyDate] timeIntervalSince1970];
                                         }];
                                     }
                            }
                               failureBlock: ^(NSError* error){
                                   DbgLog(@"error enumerating AssetLibrary groups %@\n", error);
                               }];

To play exported video I use AVPlayer instance.

Please help me - how can I solve my problem?

PS - Instagram app can do this, tested on iPhone 6. Exported video contains slow motion effect inside Instagram app.

1

There are 1 answers

2
tettoffensive On BEST ANSWER

See: https://devforums.apple.com/message/1025773#1025773

It seems that you cannot do this with the ALAssetsLibrary. However, with the new Photos framework for iOS 8+ you can use PHAssetMediaSubtypeVideoHighFrameRate