AVAssetExportSession.videoComposition has no transform animation effect in local video file.

- 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?

Accepted Reply

We've confirmed that this was fixed in the first 13.1 beta.

Replies

Today I continue check the question. find zhat only call


[transformLayerInstruction setTransform:startTransform atTime:kCMTimeZero];


after export also has no transform effect.


More simple code.


- (void)testTransformEffectExport {

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;

startTransform = CGAffineTransformTranslate(startTransform, 100, 200);

[transformLayerInstruction setTransform:startTransform atTime:kCMTimeZero];


transformInstruction.layerInstructions = [NSArray arrayWithObject:transformLayerInstruction];

videoComposition.instructions = @[transformInstruction];


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

});

}];

}

Just Now. I donwload the AVCompositionDebugVieweriOS sample code form https://developer.apple.com/library/archive , and modify the sample code , export the demo's compositon videoComposition audioMix , after export to loacl file, also has no transitions animation. iOS13 beat5.

We've also confirmed that `setTransformRamp` broke in iOS 13.

`setTransform` works as expected, but `setTransformRamp` does not work at all.

Yesterday we submitted a minimal reproducible project to Apple so hopefully they fix it!

Thanks reply!

I also submited a bug to apple.

but no any response. If apple response to you, please tell me too. thanks~!

We've confirmed that this was fixed in the first 13.1 beta.

Thanks jitae :

We verify the bug was fixed in last 13.1beta.

I have an issue with `setOpacityRamp` not working in iOS 13, is this confirmed to also a bug in iOS13?