我需要流式传输我的Mac桌面,让其他人看到我正在做的事情。我尝试过使用VLC(在当前的稳定版本中不再有效)。我已经尝试了ffmpeg,它不再适用于osx上的x11grab选项。您知道任何具有屏幕录制和流媒体功能的商业版或免费软件吗?或者可以通过管道传输到ffmpeg或vlc的东西?或者也许你可以指点我研究如何为osx构建一个非常基本的应用程序来捕获屏幕? 感谢
答案 0 :(得分:0)
这是一个示例代码,用于捕获屏幕并将其保存为适合我的文件。
/ ** 将当前屏幕记录到提到的目标路径。 ** /
- (void)screenRecording:(NSURL *)destPath {
//Create capture session
mSession = [[AVCaptureSession alloc] init];
//Set session preset
//mSession.sessionPreset = AVCaptureSessionPresetMedium;
mSession.sessionPreset = AVCaptureSessionPreset1280x720;
//Specify display to be captured
CGDirectDisplayID displayId = kCGDirectMainDisplay;
//Create AVCaptureScreenInput with the display id
AVCaptureScreenInput *input = [[AVCaptureScreenInput alloc] initWithDisplayID:displayId];
if(!input) {
//if input is null
return;
}
//if input is not null and can be added to the session
if([mSession canAddInput:input]) {
//Add capture screen input to the session
[mSession addInput:input];
}
//Create AVCaptureMovieFileOutput
mMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
mMovieFileOutput.delegate = self;
if([mSession canAddOutput:mMovieFileOutput]) {
//If movie file output can be added to session, then add it the session
[mSession addOutput:mMovieFileOutput];
}
//Start running the session
[mSession startRunning];
//Check whether the movie file exists already
if([[NSFileManager defaultManager] fileExistsAtPath:[destPath path]]) {
NSError *err;
//If the movie file exists already, then delete it
if(![[NSFileManager defaultManager] removeItemAtPath:[destPath path] error:&err]) {
NSLog(@"Error deleting existing movie file %@", [err localizedDescription]);
}
}
//Start recording to destination path using the AVCaptureMovieFileOutput
[mMovieFileOutput startRecordingToOutputFileURL:destPath recordingDelegate:self];
}
您可以在http://developer.apple.com/library/mac/#qa/qa1740/_index.html
找到示例代码请浏览网址。这可以帮助您创建捕获屏幕的基本应用程序。