我需要流式传输我的 Mac 桌面,让其他人可以观看我在做什么。我尝试过使用 VLC(在当前稳定版本中不再适用)。我已经尝试过 ffmpeg,它不再适用于 osx 上的 x11grab 选项。您知道任何具有屏幕录制和流媒体功能的商业或免费软件吗?或者可以通过管道传输到 ffmpeg 或 vlc 的东西?或者也许你能指出我某个地方来研究如何为 osx 构建一个非常基本的应用程序来捕获屏幕?谢谢
问问题
2188 次
1 回答
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找到示例代码
请通过网址。这可以帮助您至少创建捕获屏幕的基本应用程序。
于 2013-03-05T09:19:32.980 回答