Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
449 views
in Technique[技术] by (71.8m points)

iphone - How to properly export CALayer on top of AVMutableComposition with AVAssetExportSession

I know this question was asked before (for example here and here) but I just can't figure out what I'm doing wrong.

I have an AVMutableComposition that I use to combine some video clips with some CALayers that animate on top of them.

Everything works ok when I take my AVMutableComposition and combine it with an AVSynchronizedLayer for playback inside an AVPlayerLayer. The video comes out correctly and everything is positioned where it should.

My problem is that when I tried to export this thing I tried using AVVideoCompositionCoreAnimationTool instead of AVSynchronizedLayer (that's what the documentation says we should use for export) and an AVAssetExportSession, but something goes wrong because in my exported movie every CALayer has it's coordinate system reversed.

So if during playback the the 0,0 point is in the top-left corner of the screen when I export the movie the 0,0 point is in the bottom-left corner hence my animation go nuts.

I read any possible article about this and I also downloaded AVVideoEdit sample from Apple but I just can't see what is going on...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For anyone who has the same problem as I had I've finally found an answer. There is a property of every CALayer called geometryFlipped wich you need to set to YES just before exporting and everything will be ok. More information here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...