Question

The problem is this: I have a AVMutableVideoComposition which has a titleLayer (CATextLayer).

I want to display to the user a preview containing this title, using AVPlayerLayer and AVSynchronizedLayer. I setup the layer like this:

    - (CATextLayer*)buildTitleLayer {
    CATextLayer *titleLayer = [CATextLayer layer];
    // titleLayer.font = @"Helvetica";
    titleLayer.fontSize = 15.0;
    //?? titleLayer.shadowOpacity = 0.5;
    titleLayer.backgroundColor = [UIColor blackColor].CGColor;
    titleLayer.alignmentMode = kCAAlignmentCenter;
    titleLayer.frame = CGRectMake(0, 0, _videoSize.width, _videoSize.height / 6); //You may need to adjust this for proper display
    return  titleLayer;
}

When I setup the composition I do this:

    [compositionVideoTrack setPreferredTransform:clipVideoTrack.preferredTransform];

Everything runs as expected with one exception:

When I preview the end result (video+title) in the iPhone simulator I get this output:

Notice the Hello Video Label on black background on the top of the view

When I render the video using AVAssetExportSession I get this output (so the video label is on the bottom):

Notice the Hello Video Label on the bottom

Does anyone know what is the trick? What am I missing/doing wrong?

Thanks!

Was it helpful?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top