2012-07-06 77 views
2

我有一個本地的視頻文件,與GPUImage庫的幫助,我現在已經應用的過濾器, 這裏是代碼,以使過濾視頻與GPUImage我可以用GPUImage設置視頻幀嗎?

movieFile = [[GPUImageMovie alloc] initWithURL:sampleURL]; 
pixellateFilter = [[GPUImagePixellateFilter alloc] init]; 
GPUImageRotationFilter *rotationFilter = [[GPUImageRotationFilter alloc] initWithRotation:kGPUImageRotateRight]; 

[movieFile addTarget:rotationFilter]; 
[rotationFilter addTarget:pixellateFilter]; 

NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.m4v"]; 
unlink([pathToMovie UTF8String]); 
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie]; 

movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(480.0, 640.0)]; 
[pixellateFilter addTarget:movieWriter]; 

[movieWriter startRecording]; 
[movieFile startProcessing]; 

[pixellateFilter removeTarget:movieWriter]; 
[movieWriter finishRecording]; 

現在我想對這個視頻文件應用框架,我的意思我有取自然大小的視頻文件。並且想要在這個視頻文件上使用naturalSize的幀。

我該怎麼辦?可能嗎 ?

問候,

********解決********* 添加視頻那是不可能的GPUImage按我的極限了圖像.. 非常感謝這位link

+0

不可能GPUImage 因爲,我已經使用AVFoundation框架,並完成由@ MAYUR-shrivas以下代碼..獲取視頻文件的自然大小... – 2012-07-09 13:11:06

+0

http://stackoverflow.com/questions/11377917/can-i-add-uiimage-or-cgimageref-to-video/11395787#11395787 – 2012-07-09 13:14:00

回答

0

是的,你可以每GPUImage : Apply filer to existing video file

AVURLAsset *asset = [AVURLAsset URLAssetWithURLNSURL fileURLWithPath:pathToMovie] options:nil]; 
AVAssetTrack *videoAssetTrack = [[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; 
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(videoAssetTrack.naturalSize.width, videoAssetTrack.naturalSize.height)]; 
相關問題