在RubyMotion中,我使用AVFoundation进行屏幕设置,试图实现中的这个要旨。程序应该从屏幕上捕获视频并写入.mov文件。
我不太明白为什么我会犯这样的错误:
* 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我做错什么了?
发布于 2013-06-24 18:04:07
我用了一个不正确的常量来显示id。这样做是可行的:
input = AVCaptureScreenInput.alloc.initWithDisplayID(CGMainDisplayID())
https://stackoverflow.com/questions/16748047
复制相似问题