9

我知道這個問題之前(例如herehere)詢問,但我只是無法弄清楚我做錯了什麼。如何正確導出與AVAssetExportSession AVMutableComposition上的CALayer

我有一個AVMutableComposition,我使用一些視頻剪輯一些CALayer s表示在它們的頂部動畫結合起來。

一切工作正常,當我把我的AVMutableComposition並結合AVSynchronizedLayerAVPlayerLayer內播放。視頻正確顯示,所有內容都放置在應有的位置。

我的問題是,當我試圖出口這件事我用AVVideoCompositionCoreAnimationTool代替AVSynchronizedLayer(這是什麼文件說,我們應該利用出口)和AVAssetExportSession,但不順心的事嘗試,因爲在我出口的影片中每CALayer有它的座標系反轉。

所以,如果在播放過程中的0,0點在左上角角落屏幕,當我出口的電影的0,0點在左下角角落,因此我的動畫發瘋。

我讀到這個任何可能的文章,我還下載了AVVideoEdit樣品來自蘋果,但我看不出這是怎麼回事...

+0

如果你有答案我很感興趣。 – aLevelOfIndirection

+0

我從來沒有找到一個好的答案。我所做的就是在導出之前,我將包含動畫的圖層傳遞給我編寫的自定義函數,遞歸地遍歷所有子圖層並更改座標...這是一種破解和醜陋的解決方案,但它爲我。 –

+0

你能提供一些代碼嗎?我試圖做同樣的事情,不能完成它:( –

回答

15

對於任何人誰擁有,因爲我有我有同樣的問題終於找到了答案。每CALayer有一個屬性geometryFlipped至極需要設置爲YES出口之前,一切都會好的。更多信息here

+0

爲什麼這是必要的? –

0
Methods that fixing frames and points 
- (CGRect) fixRect:(CGRect)rect inRect:(CGRect)container 
{ 
    CGRect frame = rect; 
    frame.origin.y = container.size.height - frame.origin.y - frame.size.height; 
    return frame; 
} 
- (CGPoint) fixPoint:(CGPoint)point fromPoint:(CGSize)containerSize 
{ 
    CGPoint frame = point; 
    frame.y = containerSize.height - frame.y; 
    return frame; 
} 
相關問題