7 Replies
      Latest reply on Sep 24, 2019 6:39 AM by fozlong
      TianYing Level 1 Level 1 (0 points)

        - My app implement transitions animation between two video with AVFoundation's AVVideoComposition.

          In iOS13 after export to local file,it has no  transitions animation in video.

             - I used AVMutableVideoComposition build transform in video layer.

             - playerItem.videoComposition: play playerItem has transitions animation

             - but used AVAssetExportSession.videoComposition export to loacl file, has NO any effect In iOS 13.

         

         

        My sample code for verify the question:

         

         

         

         

        - (void)testTransformPlayerImage {

            NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"111" ofType:@"MP4"];

            AVAsset *asset = [AVURLAsset assetWithURL:[NSURL fileURLWithPath:moviePath]];

            AVAssetTrack *origAssetTrack = [asset tracksWithMediaType:AVMediaTypeVideo].firstObject;

          

            AVMutableComposition *composition = [AVMutableComposition composition];

            composition.naturalSize = CGSizeMake(KVideoPixelsWidth, kVideoPixelsHeight);

          

            AVMutableVideoComposition *videoComposition = [AVMutableVideoComposition videoComposition];

            videoComposition.frameDuration = CMTimeMake(1, 30);

            videoComposition.renderSize = CGSizeMake(KVideoPixelsWidth, kVideoPixelsHeight);;

          

            //////////////////////////

          

            AVMutableVideoCompositionInstruction *transformInstruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];

            transformInstruction.timeRange = origAssetTrack.timeRange;

          

            AVMutableVideoCompositionLayerInstruction *transformLayerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:origAssetTrack];

          

            CGAffineTransform startTransform = CGAffineTransformIdentity;

            CGAffineTransform endTransform = CGAffineTransformIdentity;

            endTransform = CGAffineTransformTranslate(endTransform, 0, 500);

            [transformLayerInstruction setTransformRampFromStartTransform:startTransform toEndTransform:endTransform timeRange:origAssetTrack.timeRange];

          

            transformInstruction.layerInstructions = [NSArray arrayWithObject:transformLayerInstruction];

            videoComposition.instructions = @[transformInstruction];

          

            /* has effect

            AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset];

            playerItem.videoComposition = videoComposition;

          

            combineResultTestViewController *vc = [[combineResultTestViewController alloc] initWithPlayerItem:playerItem];

            [self.navigationController pushViewController:vc animated:YES];

             */

          

            //export no effect

            NSString *outputPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"828.mp4"];

            AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPreset1280x720];

            exportSession.outputURL = [NSURL fileURLWithPath:outputPath];

            exportSession.outputFileType = AVFileTypeQuickTimeMovie;

            exportSession.videoComposition = videoComposition;

            [exportSession exportAsynchronouslyWithCompletionHandler:^{

                dispatch_async(dispatch_get_main_queue(), ^{

                    AVAsset *outputAsset = [AVURLAsset assetWithURL:[NSURL fileURLWithPath:outputPath]];

                    combineResultTestViewController *vc = [[combineResultTestViewController alloc] initWithAsset:outputAsset];

                    [self.navigationController pushViewController:vc animated:YES];

                });

            }];

        }

         

         

        What did I do wrong?