<分区>
我需要流式传输我的 Mac 桌面,让其他人可以看到我在做什么。我试过使用 VLC(在当前的稳定版本中不再有效)。我试过 ffmpeg,它不再适用于 osx 上的 x11grab 选项。您知道任何具有屏幕录制和流媒体功能的商业或免费软件吗?或者可以通过管道传输到 ffmpeg 或 vlc 的东西?或者,也许你能指出我某个地方来研究如何为 osx 构建一个非常基本的应用程序来捕获屏幕? 谢谢
<分区>
我需要流式传输我的 Mac 桌面,让其他人可以看到我在做什么。我试过使用 VLC(在当前的稳定版本中不再有效)。我试过 ffmpeg,它不再适用于 osx 上的 x11grab 选项。您知道任何具有屏幕录制和流媒体功能的商业或免费软件吗?或者可以通过管道传输到 ffmpeg 或 vlc 的东西?或者,也许你能指出我某个地方来研究如何为 osx 构建一个非常基本的应用程序来捕获屏幕? 谢谢
最佳答案
这是一个示例代码,用于捕获屏幕并将其保存为对我有用的文件。
/**
Record the current screen to the destination path mentioned.
**/
-(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 找到示例代码
请通过网址。这至少可以帮助您创建捕获屏幕的基本应用程序。
关于macos - osx 上的屏幕截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14804235/