0

GPUImage フレームワークをインポートして、ライブ ビデオ機能を備えた ios 用のカメラ アプリを作成しています。このフレームワークをライブ写真に使用しました。うまく機能していました。Brad github を参照して、ライブ ビデオに次のコードを使用しました。

videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;

startfilter = [[GPUImageFilter alloc] init];
outputView = [[GPUImageView alloc] initWithFrame:CGRectMake(0.0, 0.0,self.view.frame.size.width,self.view.frame.size.height)];
 [self.image_view addSubview:outputView];
[startfilter removeAllTargets];
// Add the view somewhere so it's visible
[startfilter forceProcessingAtSize:outputView.sizeInPixels];
[videoCamera useNextFrameForImageCapture];
[videoCamera addTarget:startfilter];
[startfilter addTarget:outputView];

[videoCamera startCameraCapture];

私の疑問: ビデオをフォト ギャラリーに保存する方法。URL を使用している他のブログを確認しましたが、フォト ギャラリーの URL を実装する方法がわかりません。次のコードを使用して、ライブ ビデオをフォト ギャラリーに保存しましたが、ビデオ キャプチャが見つかりませんでした。

[videoCamera stopCameraCapture];
UISaveVideoAtPathToSavedPhotosAlbum(pathToMovie, nil, nil, nil);

知りたいのですが、pathToMovie を見つける方法を教えてください。

助けてください。よろしくお願いします。

4

1 に答える 1

0

上記の質問を参照するために、次のコードを指定して、ライブビデオのカメラロールパスを解決しました。

pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.m4v"];

質問で言及したコード (ビデオ カメラの開始) と共に、次のコードを追加して、ライブ ビデオがバッファに入るようにします。

pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.m4v"];
unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
[movieFile addTarget:startfilter];
movie_write = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(480, 640)];
movie_write.shouldPassthroughAudio=YES;
videoCamera.audioEncodingTarget=movie_write;
[movieFile enableSynchronizedEncodingUsingMovieWriter:movie_write];
[movie_write startRecording];
[movieFile startProcessing];
[videoCamera startCameraCapture];
NSLog(@"Movie completed");

ライブビデオを保存するには、次のコードが機能します。

   [startfilter useNextFrameForImageCapture];
    UIImage*process=[[UIImage alloc]init];
    process=[startfilter imageFromCurrentFramebuffer];
     NSLog(@"Image %@",process);

    [videoCamera pauseCameraCapture];

        [startfilter removeTarget:movie_write];
        UISaveVideoAtPathToSavedPhotosAlbum(pathToMovie, nil, nil, nil);
       [movie_write finishRecording];
   [videoCamera stopCameraCapture];
于 2016-05-16T15:10:33.293 に答える