Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 通过GPUImageMovie的视频过滤器未播放干净的视频_Ios_Video_Ios7_Gpuimage_Video Editing - Fatal编程技术网

Ios 通过GPUImageMovie的视频过滤器未播放干净的视频

Ios 通过GPUImageMovie的视频过滤器未播放干净的视频,ios,video,ios7,gpuimage,video-editing,Ios,Video,Ios7,Gpuimage,Video Editing,我在项目中添加了用于视频编辑的gpuimage框架, 但它无法播放干净的视频(根据屏幕截图) 我检查了gpuimage框架中的示例,即“SimpleVideoFileFilter”, 但也有同样的问题,, 音频干净,易于保存(此处不显示电影编写器代码) 我检查了不同的视频格式,即“mp4”、“mov”、“m4v”,但有相同的问题 我的代码在下面 .h文件 #import <UIKit/UIKit.h> #import <GPUImage.h> #import

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

我的代码在下面

.h文件

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

 @interface ViewController : UIViewController<GPUImageMovieDelegate>

 @end
#导入
#进口
#进口
@界面ViewController:UIViewController
@结束
和.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...");

   }
#导入“ViewController.h”
@界面视图控制器()
{
GPUImageMovie*电影文件;
GPUImageOutput*过滤器;
GPUImageMovieWriter*movieWriter;
}
@属性(非原子,强)GPUImageView*gpuImageViewObj;
@属性(非原子,强)AVPlayer*player;
@属性(非原子,强)AVPlayerItem*playerItem;
@结束
@实现视图控制器
@合成gpuImageViewObj、播放器、播放器项;
-(无效)viewDidLoad
{
[超级视图下载];
gpuImageViewObj=[[GPUImageView alloc]initWithFrame:CGRectMake(0,0568320)];
[self.view addSubview:gpuImageViewObj];
[自我尝试128];
}
-(无效)try128{
//AVplayer
NSURL*sampleURL=[[NSBundle mainBundle]URLForResource:@“Sample”带扩展名:@“m4v”];
playerItem=[[AVPlayerItem alloc]initWithURL:sampleURL];
player=[[AVPlayer alloc]initWithPlayerItem:playerItem];
[玩家游戏];
//GPUImage电影
movieFile=[[GPUImageMovie alloc]initWithPlayerItem:playerItem];
//movieFile.runBenchmark=是;
movieFile.playAtActualSpeed=是;
movieFile.delegate=self;
//滤器
filter=[[GPUImageFilter alloc]init];
[filter Force ProcessingAtSize:gpuImageViewObj.sizeInPixels];
[movieFile addTarget:filter];
[过滤器添加目标:gpuImageViewObj];
[电影文件启动处理];
player.actionAtItemEnd=AVPlayerActionAtItemEndNone;
[[NSNotificationCenter defaultCenter]添加观察者:self
选择器:@selector(didCompletePlayingMovie)
名称:AVPlayerItemDidPlayToEndTimeNotification
对象:无];
}
#pragma标记-GPUImageMovieDelegate
-(无效)未完成播放电影
{
[[NSNotificationCenter defaultCenter]removeObserver:self name:AVPlayerItemDidPlayToEndTimeNotification对象:nil];
[过滤器移除目标:电影编剧];
//[movieFile endProcessing];//不需要
NSLog(@“饰面…………”);
}
#pragma标记-GPUImageMovieWriterDelegate
-(作废)电影录制完成{
NSLog(@“movieRecordingCompleted called…”);
//[电影编剧finishRecording];
}
-(无效)MovierRecordingFailedWitherRor:(n错误*)错误{
NSLog(@“MovieRecordingFailedWitheror调用…”);
}
我的o/p图像


我猜您是想在模拟器中运行它,而不是在实际设备上运行。电影播放从来没有在模拟器上正常工作过,这就是其中的一个假象


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

Yuppiiiii。。。它的工作最终要归功于@brad larson的建议