Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/galargh/pavo

Swift framework for continuous display capture
https://github.com/galargh/pavo

Last synced: 17 days ago
JSON representation

Swift framework for continuous display capture

Awesome Lists containing this project

README

        

# pavo

Pavo is an OSX framework written in Swift responsible for continuous and
efficient display capture.

### pavo
The framework was named after all the [Peafowls](http://en.wikipedia.org/wiki/Peafowl)
and the wonderful 'display' they have.

### How to include the framework in a project?
1. Clone the Pavo repository
```
git clone https://github.com/gfjalar/pavo.git
```
2. Open the project in XCode and build it
3. In XCode, right click Pavo/Products/Pavo.framework and 'Show in Finder'
4. Drag & drop Pavo.framework in the project
5. Inside the project(General settings) add Pavo.framework to
'Embedded Binaries'

*I found [Haroon Baig's post](https://medium.com/@PyBaig/build-your-own-cocoa-touch-frameworks-in-swift-d4ea3d1f9ca3) very helpful when creating the framework*

### Usage

To import:
```swift
import Pavo
```

To create new monitor:
```swift
// Display monitor constructor takes:
// duration of the capture session in seconds
// number of frames captured per second
// the id of the display to capture
let monitor = DisplayMonitor(duration: 10, fps: 25, display: CGMainDisplayID())
```

To start the continuously capturing the display:
```swift
monitor.start()
```

To stop the session:
```swift
monitor.stop()
```

To get the current state of the capturing session:
```swift
// It will return nil if the session has not been started previously
let frames: [CGImage] = monitor.takeCaptured()
```

To take a screen shot:
```swift
// It does not require capturing session to be running
let screenShot: CGImage = monitor.takeScreenShot()
```

To clear the buffer holding the state of the capturing session:
```swift
monitor.clearCaptured()
```

To save CGImage as a PNG:
```swift
screenShot.saveAsPNG(to: "/Users/gfjalar/ScreenShots/", with: "display")
```

To save array of CGImages as a series of PNGs:
```swift
// Index will be appended to the name of each frame
SaveAsPNG(frames, to: "/Users/gfjalar/ScreenShots/series/", with: "shot")
```

To save array of CGImages as MPEG4:
```swift
SaveAsMPEG4(frames, to: "/Users/gfjalar/Films/", with: "film", 25,
kCVPixelFormatType_32BGRA, 20000*1000, AVVideoProfileLevelH264HighAutoLevel)
```

### TODO:
* debugging and testing
* memory management
* error handlilng on save
* existing video file handling
* examples, how it works