Search code examples
avplayeravvideocomposition

AVVideocomposition AVPlayerItem position of video-layer


I used Apple's AVEdit-Demo, tweaked it a little and was able to add CALayers with animations and images to the video-composition. So far, this works fine.

It uses AVVideoComposition and AVPlayer/AVPlayerItem to merge videos (and show them - the export rendering is a little different).

I added a layer with a png with some transparent areas, sort of like a mask, that hides parts of the video. Now I need to move the video-layer, so I can adjust the hidden parts (a.k.a. the visible part). The Mask covers the whole screen (in a CALayer), so moving the Mask-Layer isn't an option.

I didn't find any properties or methods, to adjust the position of the video-layer...

Any Ideas?


Solution

  • Found it...

    I had to access the AVMutableCompositionTrack in the AVMutableVideoComposition and set the preferredTransform there (CGAffineTransformTranslate).

    However - the Docs state, that this should be possible in a AVMutableComposition as well (AVAssetTrack setPreferredTransform). I couldn't get this to work, though.