Skip to content

p-x9/ScreenCapture

Repository files navigation

ScreenCapture

Library for recording window and windowScene.
It is possible to use this function even when screen recording is being performed by an iOS function or while screen sharing is in progress.

Github issues Github forks Github stars Github top language

Document

Instance

import ScreenCapture

// config for recording
let config = Configuration(
    codec: .h264,
    fileType: .mp4,
    fps: 60,
    scale: 2
)

// record all windows in a scene
let screenCapture = ScreenCapture(for: windowScene,
                                  with: config)

// record a particular window
let screenCapture = ScreenCapture(for: window,
                                  with: config)

Video

Start Recording

let tmpURL = FileManager.default.temporaryDirectory
let url = tmpURL.appending(components: UUID().uuidString + ".mp4")

try screenCapture.start(outputURL: url)

End Recording

try screenCapture.end()

Image

let tmpURL = FileManager.default.temporaryDirectory
let url = tmpURL.appending(components: UUID().uuidString + ".jpg")

try screenCapture.capture(outputURL: url)

License

ScreenCapture is released under the MIT License. See LICENSE