RubyMotion では、Mac 開発者ライブラリからこの要点を実装しようとして、スクリーン キャプチャに AVFoundation を使用しています。プログラムは、画面からビデオをキャプチャし、.mov ファイルに書き込む必要があります。
このエラーが発生する理由がよくわかりません。
* -[AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] - アクティブ/有効な接続がありません。
簡単なコードは次のとおりです。
# 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
私は何を間違っていますか?