ios - 在 Instagram 中打开 AVMutableComposition 时出现白色视频

标签 ios instagram instagram-api avassetexportsession avmutablecomposition

导出AVMutableComposition 后,我使用PHPhotoLibrary 将视频保存到相机胶卷。在 creationRequestForAssetFromVideoAtFileURL: 完成处理程序中,我然后在 Instagram 中打开保存的视频,如下所示:

__block PHObjectPlaceholder *videoAssetPlaceholder;

[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
    PHAssetChangeRequest *req = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:localVideoURL];
    videoAssetPlaceholder = req.placeholderForCreatedAsset;
} completionHandler:^(BOOL success, NSError *error) {
    if (success) {
        completion(YES);
        NSString *localID = videoAssetPlaceholder.localIdentifier;
        NSRange rangeOfSlash = [localID rangeOfString:@"/"];
        if (rangeOfSlash.location != NSNotFound) {
            NSString *assetID = [localID substringToIndex:rangeOfSlash.location];
            NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@", assetID]];
            if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
                [[UIApplication sharedApplication] openURL:instagramURL];
            }
        }
    }
}];

大约 50% 的 Instagram 打开和视频播放都符合预期。然而,另外 50% 的时间,视频和预览都是白色的,我得到的只是声音。这通常可以通过选择另一个视频然后返回到我的视频来解决。视频在相机胶卷中完美播放,只有 Instagram 才会出现问题。这是 Instagram 存在的问题还是我可能以错误的方式导出我的视频?

这些是我的 AVAssetExportSession 设置:

AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:mixComposition
                                                                  presetName:AVAssetExportPresetHighestQuality];
exporter.outputURL = url;
exporter.outputFileType = AVFileTypeMPEG4;
exporter.shouldOptimizeForNetworkUse = YES;
exporter.videoComposition = mainCompositionInst;
[exporter exportAsynchronouslyWithCompletionHandler:^{
    dispatch_async(dispatch_get_main_queue(), ^{
        handler(exporter.outputURL);
    });
}];

最佳答案

刚从 Apple DTS 听说。他们也同意这指向 Apple iOS 错误并要求我记录它。

我像上面提到的那样切断了 AVAssetExportSession 的使用,它解决了我的问题。所以问题似乎与您正在使用的 Instagram 方法中可能包含的方法有关。

因此,在 Apple 修复此问题或 Instagram 构建解决方案之前,似乎没有解决此问题的方法……真可惜

关于ios - 在 Instagram 中打开 AVMutableComposition 时出现白色视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39300675/

相关文章:

ios - WatchKit Catalog 示例代码错误

ios - iPad 应用程序永远不会安装在 Retina 模拟器中

ios - 一种使用 UIPinchGestureRecognizer UIRotationGestureRecognizer 和 UIPanGestureRecognizer 添加 Instagram 类布局指南的方法?

android - 如何从 Android 中的 Instagram 注销?

instagram-api - 可以通过 Instagram API 提取见解数据吗?

ios - 在iOS aarch64应用程序中使用内联汇编器

ios - swift -addConstraint : Cannot convert expression's type (constraint: [AnyObject] )' to type ' StringLiteralConvertible'

php - Laravel5.4 中 Instagram 登录 OAuth 问题

php - 获取 Instagram 帖子的 JSON

php - 没有 ProfilePage 索引,但我有 LoginAndSignupPage