GPUImage
ライブラリを使用して、ビデオをファイルシステム上のファイルに記録しています。私はm4vファイルとして保存します。これは私が使用しているコードです:GPUImageでビデオレコーダーを再生できません
NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:recordingDestination];
unlink([pathToMovie UTF8String]);
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(1280.0, 720.0)];
[videoCameraFilter addTarget:movieWriter];
movieWriter.shouldPassthroughAudio = YES;
movieFile.audioEncodingTarget = movieWriter;
[movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];
[movieWriter startRecording];
[movieFile startProcessing];
[movieWriter setCompletionBlock:^{
[videoCameraFilter removeTarget:movieWriter];
[movieWriter finishRecording];
}];
これはm4vビデオを記録します。私はその後、MPMoviePlayerController
でそれを再生しよう:
NSString *videoPath = [NSString stringWithFormat:@"%@/%@", [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"], [libraryFiles objectAtIndex:selectedCell]];
NSLog(videoPath);
NSURL *url=[[NSURL alloc] initWithString:videoPath];
MPMoviePlayerController *moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDonePressed) name:MPMoviePlayerDidExitFullscreenNotification object:moviePlayer];
moviePlayer.controlStyle=MPMovieControlStyleDefault;
[moviePlayer play];
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
しかし、プレイヤーはただのバッファリングを開始し、何も起こりません。ビデオの再生が開始されません。プレイヤーは永遠にバッファリングしています。アプリはクラッシュせず、コンソールに警告が表示されないので、何が問題なのか分かりません。
あなたがビデオをチェックして保存先にあるのでしょうか?ビデオが破損していないことを確認するためにPCにダウンロードして再生してください – Ushan87