2011-10-26 6 views
0
어떤 비디오 미리보기를 가져올 수 없습니다

내가 설정 내 AVCaptureSession과 같이 : 내보기로 미리보기 레이어를 추가 한 후가 AVCaptureSession

AVCaptureSession *newSession = [[AVCaptureSession alloc] init]; 
AVCaptureDevice *camera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 

NSError *error = nil; 

AVCaptureDeviceInput *newInput = [[AVCaptureDeviceInput alloc] initWithDevice:camera error:&error]; 


if(error) { 
    NSLog([error localizedDescription]); 

} 

AVCaptureMovieFileOutput *newOutput = [[AVCaptureMovieFileOutput alloc] init]; 


if([newSession canAddInput:newInput]) 
    [newSession addInput:newInput]; 
if ([newSession canAddOutput:newOutput]) 
    [newSession addOutput:newOutput]; 

[self setSession:newSession]; 
[self setInput:newInput]; 
[self setOutput:newOutput]; 

그리고 :

AVCaptureVideoPreviewLayer *layer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:[recorder session]]; 

[layer setBounds:[recordingView bounds]]; 
[layer setVideoGravity:AVLayerVideoGravityResizeAspectFill]; 

[[recordingView layer] insertSublayer:layer above:[recordingView layer]]; 

그러나 나는 늘 하나를 얻을 시사.

나는 아이팟 터치 4 창

감사와 IOS 5입니다.

답변

2

우선, 귀하의 recordingView은 어떻게 정의됩니까? 둘째,

[[recordingView layer] insertSublayer:layer above:[recordingView layer]]; 

은 의미가 없습니다. (당신은 자신의 레이어 내에서 레이어를 추가하려고합니다 -> duh?) [recordingView.layer addSublayer:layer];을 대신 시도하십시오.

주석에 게시 된 프로젝트는 제로가 약한 포인터를 사용합니다. 귀하의 재산을 강하게 표시하면 모든 것이 효과가 있습니다.

+0

'recordingView'는 제 'MainViewController' 내부의 UIView입니다. 변경되었지만 수정하지 못했습니다 ... – tonekk

+0

init 후에도 세션을 시작해야합니다. '[newSession startRunning]; ' – yinkou

+0

글쎄, 그냥 복사하는 걸 깜빡 했어. 다른 곳에서 문제가 있다고 생각합니다 ... 다음은 전체 프로젝트입니다 (허용되는 경우 ...) : http://www21.zippyshare.com/v/26365272/file.html 그다지, 단지 5 개의 클래스 정도. – tonekk

관련 문제