2013-05-25 2 views
0

RubyMotion에서 나는 Mac 개발자 라이브러리에서 this gist을 구현하기 위해 screencapture에 AVFoundation을 사용하고 있습니다. 프로그램은 화면에서 비디오를 캡처하고 .mov 파일에 기록해야합니다.AVCaptureMovieFileOutput - 활성/비활성 연결 없음

꽤 나는이 오류를 받고 있어요 이유를 이해하지 않습니다

* -[AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] - no active/enabled connections.

간단한 코드입니다 : 내가 잘못 뭐하는 거지

# Setup recording pipeline 
@session = AVCaptureSession.alloc.init 
@session.sessionPreset = AVCaptureSessionPresetMedium 
input = AVCaptureScreenInput.alloc.initWithDisplayID(KCGDirectMainDisplay) 
@session.addInput(input) 
movieFileOutput = AVCaptureMovieFileOutput.alloc.init 
if @session.canAddOutput(movieFileOutput) 
    @session.addOutput(movieFileOutput) 
else 
    Logger.error "Could not add ouput #{movieFileOutput}" 
end 
@session.startRunning() 

# Delete exisiting file 
fileManager = NSFileManager.defaultManager 
path = "~/Desktop/video.mov" 
if fileManager.fileExistsAtPath(path) 
    err = Pointer.new(:object) 
    unless fileManager.defaultManager.removeItemAtPath(path, error:err) 
    Logger.error "Can't delete existing movie" 
    end 
end 

# Start recording 
movieFileOutput.startRecordingToOutputFileURL(NSURL.fileURLWithPath(path), recordingDelegate:self) # <--- Problem 

?

답변

1

표시 ID에 잘못된 상수를 사용했습니다. 작동 방식 :

input = AVCaptureScreenInput.alloc.initWithDisplayID(CGMainDisplayID())