在iPhone 6/6 +上从相机胶卷视频导出时没有慢动作效果

时间:2015-06-21 22:29:42

标签: ios objective-c iphone video slowmotion

我正在开发适用于视频的应用。它可以通过相机胶卷视频录制或导出短片。我需要一些意外行为的帮助。

当我导出用苹果慢动作效果录制的视频时 - 我的应用中的视频效果会丢失。

这在iPhone 6和6+上再现,我也假设在iPhone 5s上。在iPhone 5s / 6/6 +模拟器上,一切正常。要导出视频,我使用iOS SDK ALAssetsLibrary API,代码:

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);
                               }];

要播放导出的视频,请使用 AVPlayer 实例。

请帮助我 - 我该如何解决我的问题?

PS - Instagram应用程序可以执行此操作,在iPhone 6上测试。导出的视频包含Instagram应用程序内的慢动作效果。

1 个答案:

答案 0 :(得分:3)

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