I'm making an app to manipulate video, now I m adding sprite animation above the video.
For that I m using CAKeyframeAnimation, I have a method in a Manager that is adding the animated sprite.
// add effect on the video
[EffectManager addEffectOnVideoAtURL:outputURL handler:^{
NSLog(@"video exported with aimations");
}];
The thing is that when this videoURL is stored in the document folder of my app, the CAKeyframeAnimation is not visible.
But when I first export the video to the Library/camera roll, and then load and add the effect on this exported video, they are visible.
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
// export the video to the library/camera roll
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:outputURL]) {
[library writeVideoAtPathToSavedPhotosAlbum:outputURL completionBlock:^(NSURL *assetURL, NSError *error){
dispatch_async(dispatch_get_main_queue(), ^{
// add effect on the video
[EffectManager addEffectOnVideoAtURL:assetURL handler:^{
NSLog(@"video exported with aimations");
}];
});
}];
}
This code, using the library is working correctly, but I don t want to have to save a intermediate video to the library.
I have tried to use the first snippet of code in a async way, but the result is the same.
I have tried also to load a movie from the library, and use the first snippet of code, but same result, no CAKeyframeAnimation.
Any idea why CAKeyframeAnimation is visible only when the video is first exported to the lbrary/photo roll ?