2013-03-07 33 views
1

我正在嘗試自己的一些視頻編輯,我有序化和混合視頻/音頻一起工作正常,甚至一些基本的慢動作! :) 現在我想要集成視頻濾鏡,不僅僅是圖層本身(否則我會在CIFilter的公司中使用AVPlayerItemVideoOutput),而且還會導出最終的視頻文件。 因此,我目前正在研究將上面提到的CIFilter「渲染」到最終視頻中,同時仍然使用CMTime保持對時序的非常精確的控制。AVFoundation&Video Effects

有什麼建議嗎?

+0

您是否能夠找到解決此問題的直接解決方案?一種方法是使用AVAssetReader和AVAssetWriter編寫AVAssetExportSession的自定義實現,但這會涉及很多工作。 – 2013-05-01 12:48:15

+1

看看GPUImageFilter,它非常棒。 – 2013-05-03 08:51:53

回答

2

您可以使用AVVideoCompositingAVAsynchronousVideoCompositionRequest協議來實現自定義合成器。

CVPixelBufferRef pixelBuffer = [AVAsynchronousVideoCompositionRequest sourceFrameByTrackID:trackID]; 
CIImage *theImage = [CIImage imageWithCVPixelBuffer:pixelBuffer]; 
CIImage *motionBlurredImage = [[CIFilter *filterWithName:@"CIMotionBlur" keysAndValues:@"inputImage", theImage, nil] valueForKey:kCIOutputImageKey]; 
CIContext *someCIContext = [CIContext contextWithEAGLContext:eaglContext]; 
[someCIContext render:motionBlurredImage toCVPixelBuffer:outputBuffer]; 

然後使用OpenGL渲染像素緩衝區,如Apple's Documentation中所述。這將允許您實現任意數量的所需轉換或過濾器。

+0

有沒有關於如何做到這一點的示例項目? – izzy 2015-10-21 20:58:18

+0

好的,我在ios開發人員庫中找到了一個示例項目,供他接下來發現此問題的人使用,AVCustomEdit位於https://developer.apple.com/library/ios/samplecode/AVCustomEdit/Listings/ReadMe_txt.html乾杯! – izzy 2015-10-21 22:29:18