2014-06-19 4 views
2

Instagram과 같은 응용 프로그램을 만들고 있습니다. GPUImage 프레임 워크를 사용하고 있습니다. 사진과 비디오를 공유하고 공유해야합니다. 나는이 프레임 워크를 사용하여 사진을 캡처 할 수 있고 이제는 비디오를 캡쳐해야하지만 카메라 모드 사진을 비디오로 변경하는 방법에 어려움을 겪고 있습니다. 어떤 도움과 튜토리얼은 나에게 매우 좋다. 나는이 코드 카메라를 사진 모드로 사용했다.iOS에서 GPUImage를 사용하여 카메라 모드를 비디오 모드로 전환하는 방법

if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 
{ 
    self.imagepicker.sourceType = UIImagePickerControllerSourceTypeCamera; 

    [[NSBundle mainBundle] loadNibNamed:@"OverlayView" owner:self options:nil]; 
    self.overlayView.frame = self.imagepicker.cameraOverlayView.frame; 
    self.imagepicker.cameraOverlayView = self.overlayView; 
    self.overlayView = nil; 

    CGSize result = [[UIScreen mainScreen] bounds].size; 

      self.imagepicker.showsCameraControls = NO; 

    self.imagepicker.allowsEditing = NO; 
    self.imagepicker.wantsFullScreenLayout = NO; 
    // self.imagepicker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil]; 

} 
else{ 
    self.imagepicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
} 
+0

혹시이 문제를 해결 않았다을? –

답변

0

내 경우 GPUImage를 사용하여 사진과 비디오를 모두 처리합니다. 따라서 GPUImageStillCamera (그림) 유형과 GPUImageVideoCamera (비디오) 유형의 두 가지 객체를 만들었습니다. 당신이 카메라를 전환해야 할 때마다

그래서 당신은 기본적으로 GPUImageStillCamera 캡처를 중지하고 비디오 카메라 (프로젝트에이 코드를 적용 할 필요가 있습니다) 초기화 :

func initializeVideoCamera() { 

    // Stop the capture of GPUImageStillCamera 
    stillCamera.stopCameraCapture() 

    videoCamera = GPUImageVideoCamera.init(sessionPreset: AVCaptureSessionPreset1920x1080, cameraPosition: .Back) 
    videoCamera?.outputImageOrientation = .Portrait 
    videoCamera?.addTarget(filter) 

    // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie 
    unlink(pathToMovieFile) 

    initializeWriteWithPath(pathToMovieFile) 

    videoCamera?.startCameraCapture() 
} 
관련 문제