Search code examples
iosobjective-cvideovideo-streamingavmutablecomposition

Merge Video Side by Side in sequence mode


I merge two videos side by side in sequence mode by using AVMutableComposition, play two videos one after another, I can do this successfully. My problem is that while Playing the first video, the second video screen will display a blank screen until it completes the first video. Can anyone give me a solution to show the thumbnail image of the second video while playing the first one?


Solution

  • We can display the thumbnail image on the video by using the following code.

    CALayer *firstThumbnailOverlay=[CALayer layer]; 
    CABasicAnimation *firstfadeAnimation;
    
    firstfadeAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
    
    firstfadeAnimation.fromValue = [NSNumber numberWithFloat:1.0];
    firstfadeAnimation.toValue = [NSNumber numberWithFloat:0.0];
    firstfadeAnimation.additive = NO;
    firstfadeAnimation.removedOnCompletion = NO;
    firstfadeAnimation.beginTime = CMTimeGetSeconds(firstAsset.duration);
    firstfadeAnimation.duration = 0.0;
    firstfadeAnimation.fillMode = kCAFillModeBoth;
    [firstThumbnailOverlay addAnimation:firstfadeAnimation forKey:Nil];
    [parentLayer addSublayer:firstThumbnailOverlay];