0

120FPSで動画を撮影しました。SLOW_Mo動画です。そのビデオを PHImageManager を使用して CameraRoll にエクスポートする場合。VIDEO Effectはslow_moなので大丈夫です。QuickPlayer と AVPlayer を使用して再生でき、効果は 120FPS です。

これは私の作業コードです:

  PHAsset *oneVideo = [[PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeVideo options:nil] lastObject];
    PHVideoRequestOptions *options = [PHVideoRequestOptions new];
    options.networkAccessAllowed = YES;
    options.version = PHVideoRequestOptionsVersionCurrent;
    options.deliveryMode = PHVideoRequestOptionsDeliveryModeHighQualityFormat;
    [[PHImageManager defaultManager] requestAVAssetForVideo:oneVideo options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
        if(([asset isKindOfClass:[AVComposition class]])){
            BOOL bResult = FALSE;
            DebugLog(@"\navPlayer.outputFileURL.absoluteString:%@", URl);
            bResult = [[NSFileManager defaultManager] removeItemAtURL:URl error:nil];
            DebugLog(@"\nremoveItemAtPath:%d", bResult);
            //Begin slow mo video export
            AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality];
            exporter.outputURL = avPlayer.outputFileURL;
            // exporter.outputURL = urlFirstVideoPath;
            exporter.outputFileType = AVFileTypeQuickTimeMovie;
            exporter.shouldOptimizeForNetworkUse = YES;

            [exporter exportAsynchronouslyWithCompletionHandler:^{
                NSLog(@"Video test run exported video into file: %@", exporter.outputURL);
                NSLog(@"exportSession.status: %ld", (long)exporter.status);
                dispatch_async(dispatch_get_main_queue(), ^{
                    if (exporter.status == AVAssetExportSessionStatusCompleted) {
                        NSLog(@"exportSession.status: okkkkkkk");
                    }
                });
            }];

        }
    }];

今、そのビデオをCAMERAROLLに保存したくありません。動画を Document フォルダに保存しました。AVAssets を取得します。しかし、効果は slow_mo 120FPS ではありません。それについて読んだところ、slow_mo ビデオのエクスポートには AVComposition を使用する必要があることがわかりました。しかし、私はそれを行うことができません。以下は私の動作しないコードです。

    AVAsset *assetURL = [AVURLAsset URLAssetWithURL:URl options:nil];

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = paths.firstObject;
    NSString *myPathDocs =  [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"mergeSlowMoVideo-%d.mov",arc4random() % 1000]];
    NSURL *_filePath = [NSURL fileURLWithPath:myPathDocs];

    AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:assetURL presetName:AVAssetExportPresetHighestQuality];
    exporter.outputURL = _filePath;
    exporter.outputFileType = AVFileTypeQuickTimeMovie;
    exporter.shouldOptimizeForNetworkUse = YES;
    [exporter exportAsynchronouslyWithCompletionHandler:^{ //start
        NSLog(@"Export failed: %@", [[exporter error] localizedDescription]);
        NSLog(@"Video test run exported video into file: %@", exporter.outputURL);
        NSLog(@"export  %ld", (long)exporter.status);
        dispatch_async(dispatch_get_main_queue(), ^{
            if (exporter.status == AVAssetExportSessionStatusCompleted) {

            }
        });
    }];

専門家が私を助けてください。

更新: これは私の実際の問題です。

この質問には、実際の問題の説明があります

4

0 に答える 0