在Instagram中打开AVMutableComposition时的白色视频 [英] White video when opening AVMutableComposition in Instagram

查看:193
本文介绍了在Instagram中打开AVMutableComposition时的白色视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

After I export an AVMutableComposition I use PHPhotoLibrary to save the video to the camera roll. In the creationRequestForAssetFromVideoAtFileURL: completion handler, I then open the saved video in Instagram, like so:

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

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

About 50% of the times Instagram opens and the video plays like expected. The other 50% of the times, however, both the video and the preview is white, and all I get is the sound. This usually gets fixed by selecting another video and then going back to my video. The video plays perfectly in the camera roll, it's only Instagram that causes problems. Is this an issue that Instagram has or could I be exporting my videos the wrong way?

这些是我的 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的错误并要求我记录它。

Just heard from Apple DTS. They also agree this points to an Apple iOS bug and asked me to log it.

我减少了 AVAssetExportSession 如上所述,它解决了我的问题作为一种解决方法。所以这个问题似乎与你正在使用的Instagram方法中包含的方法有关。

I cut out usage of AVAssetExportSession like mentioned above and it solved my problem as a work around. So the issue seems to be around that method which is probably contained in the Instagram method you are using.

因此,在Apple修复此问题或Instagram构建解决方案之前,似乎没有针对此问题的解决方案...... Bummer

So until Apple fixes this or Instagram builds a work around, there does not seem to be a solution for this problem... Bummer

这篇关于在Instagram中打开AVMutableComposition时的白色视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆