BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.25k stars 4.61k forks source link

Use filter output in AVComposition #1388

Open scttnlsn opened 10 years ago

scttnlsn commented 10 years ago

I'd like to be able to use the output of GPUImage filters in my AVComposition. Right now I setup the tracks from the raw AVAsset:

self.url = url;
self.asset = [AVURLAsset assetWithURL:self.url];

self.composition = [AVMutableComposition composition];
self.playerItem = [AVPlayerItem playerItemWithAsset:self.composition];

self.videoTrack = [self.composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
self.audioTrack = [self.composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];

self.video = [[self.asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
[self.videoTrack insertTimeRange:self.video.timeRange ofTrack:self.video atTime:kCMTimeZero error:nil];

self.audio = [[self.asset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
[self.audioTrack insertTimeRange:self.audio.timeRange ofTrack:self.audio atTime:kCMTimeZero error:nil];

Is it possible to construct a video track that is the output of various GPUImage filters? i.e.

GPIImageMovie *movie = [[GPUImageMovie alloc] initWithAsset:self.asset];
GPUImageFilter *filter = // some filter
[movie addTarget:filter];

...

self.video = // Somehow get AVAssetTrack from filter output
[self.videoTrack insertTimeRange:self.video.timeRange ofTrack:self.video atTime:kCMTimeZero error:nil];
imran4125 commented 10 years ago

did u find any answer to this ??