CaptureKit 1.0.0

CaptureKit 1.0.0

Nikita Vasilev 维护。



  • 作者
  • Nikita Vasilev

capture-kit: a framework written in Objective-C that provides functions that can be used to capture the contents of a screen

capture-kit

Liscence CI CodeCov

描述

capture-kit 是一个用 Objective-C 编写的框架,提供用于捕获屏幕内容的函数。

用法

  1. 创建一个包含屏幕捕获功能的 NVCaptureService 实例。
NVCaptureService *captureService = [[NVCaptureService alloc] init];
  1. 设置一个委托以接收与录制相关的事件
captureService.delegate = self;
  1. 可选步骤:如果您想捕获麦克风声音,您需要获取麦克风 ID。为此,创建一个提供设备 ID 列表的 NVAudioService 实例。
NVAudioService *audioService = [[NVAudioService alloc] initWithMediaDeviceProvider:[NVMediaDeviceProvider new]];
NSArray<NSString *> *ids = [audioService audioDevicesIDs];

您也可以这样检查是否已连接音频设备

BOOL isConnected = [audioService isAudioDeviceConnected:@"<device_id_here>"];
  1. 开始屏幕捕获
NSRect sampleRect = CGRectMake(0, 0, 1200, 1800);
NSURL *sampleURL = [[NSURL alloc] initWithString:@"file_url"];

[_captureService startRecordingWithAudioDeviceID:@"<device_id_here>"
                                            rect:sampleRect
                                 directDisplayID:kCGDirectMainDisplay
                                   outputFileURL:sampleURL];

此外,您还可以使用 objc - (void)startRecordingWithConfiguration:deviceID:rect:directDisplayID:outputFileURL: 传递自定义捕获配置

  1. 对于暂停,恢复和取消,您可以使用以下方法
- (void)pause
- (void)resume
- (void)stop

要求

  • macOS 11.0+
  • Xcode 14.0

通讯

  • 如果您 发现了一个错误,请打开一个问题。
  • 如果您 有一个功能请求,请打开一个问题。
  • 如果您 想贡献,提交一个拉取请求。

贡献

建立开发环境

make bootstrap

请随意为本项目提供帮助!如果您发现可以改进的地方或想要新功能,请打开一个问题或发送一个 Pull Request!

作者

Nikita Vasilev, [email protected]

许可

capture-kit 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。