【问题标题】:video filter via GPUImageMovie not played clean video通过 GPUImageMovie 的视频过滤器未播放干净的视频
【发布时间】:2014-08-08 18:35:01
【问题描述】:

我在我的项目中添加了用于视频编辑的 gpuimage 框架, 但它不能干净地播放视频(根据屏幕截图) 我检查了 gpuimage 框架中的示例,即“SimpleVideoFileFilter”, 但它也有同样的问题, 音频干净,易于保存(此处未显示电影作者代码) 我检查了不同的视频格式,即“mp4”、“mov”、“m4v”,但有同样的问题

我的代码如下,

.h 文件

  #import <UIKit/UIKit.h>
  #import <GPUImage.h>
  #import <AVFoundation/AVFoundation.h>

 @interface ViewController : UIViewController<GPUImageMovieDelegate>

 @end

.m 文件在后面

#import "ViewController.h"

@interface ViewController ()
{
GPUImageMovie *movieFile;
GPUImageOutput<GPUImageInput> *filter;
GPUImageMovieWriter *movieWriter;
}
@property (nonatomic,strong) GPUImageView *gpuImageViewObj;
@property (nonatomic,strong) AVPlayer *player;
@property (nonatomic,strong) AVPlayerItem *playerItem;
@end

@implementation ViewController
@synthesize gpuImageViewObj,player,playerItem;

- (void)viewDidLoad
{
    [super viewDidLoad];

    gpuImageViewObj = [[GPUImageView alloc] initWithFrame:CGRectMake(0, 0, 568, 320)];
    [self.view addSubview:gpuImageViewObj];


    [self try128];

 }

 -(void)try128{


   //AVplayer
   NSURL *sampleURL = [[NSBundle mainBundle] URLForResource:@"Sample"  withExtension:@"m4v"];
playerItem = [[AVPlayerItem alloc]initWithURL:sampleURL];
player  = [[AVPlayer alloc ]initWithPlayerItem:playerItem];
[player play];


//GPUImage movie
movieFile = [[GPUImageMovie alloc] initWithPlayerItem:playerItem];
//    movieFile.runBenchmark = YES;
movieFile.playAtActualSpeed = YES;
movieFile.delegate = self;

//filter
filter = [[GPUImageFilter alloc] init];
[filter forceProcessingAtSize:gpuImageViewObj.sizeInPixels];

[movieFile addTarget:filter];
[filter  addTarget:gpuImageViewObj];


[movieFile startProcessing];


player.actionAtItemEnd = AVPlayerActionAtItemEndNone;

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(didCompletePlayingMovie)
                                             name:AVPlayerItemDidPlayToEndTimeNotification
                                           object:nil];

  }


 #pragma mark - GPUImageMovieDelegate

 -(void)didCompletePlayingMovie
 {
     [[NSNotificationCenter defaultCenter] removeObserver:self name:AVPlayerItemDidPlayToEndTimeNotification object:nil];

    [filter removeTarget:movieWriter];
       //    [movieFile endProcessing];  //not needed
     NSLog(@"finish............");

    }


     #pragma mark -GPUImageMovieWriterDelegate


   - (void)movieRecordingCompleted{
      NSLog(@"movieRecordingCompleted called...");

     //    [movieWriter finishRecording];

    }
  - (void)movieRecordingFailedWithError:(NSError*)error{
        NSLog(@"movieRecordingFailedWithError called...");

   }

我的 o/p 图片

【问题讨论】:

    标签: ios video ios7 gpuimage video-editing


    【解决方案1】:

    我猜你是想在模拟器中运行它,而不是在实际设备上。电影播放从未在模拟器上正常工作,这就是其中之一。

    相反,在实际的 iOS 硬件上进行开发。

    【讨论】:

    • Yuppiiiii... 它的工作终于感谢@brad-larson 的建议
    猜你喜欢
    • 2020-07-24
    • 1970-01-01
    • 2011-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-11
    • 2021-06-08
    相关资源
    最近更新 更多