Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MetalPetal/VideoIO
Video Input/Output Utilities
https://github.com/MetalPetal/VideoIO
audio avfoundation camera ios macos player video video-processing
Last synced: 3 months ago
JSON representation
Video Input/Output Utilities
- Host: GitHub
- URL: https://github.com/MetalPetal/VideoIO
- Owner: MetalPetal
- License: mit
- Created: 2019-12-19T05:24:47.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-06T12:23:34.000Z (7 months ago)
- Last Synced: 2024-07-22T01:42:23.665Z (4 months ago)
- Topics: audio, avfoundation, camera, ios, macos, player, video, video-processing
- Language: Swift
- Homepage:
- Size: 3.45 MB
- Stars: 167
- Watchers: 7
- Forks: 29
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# VideoIO
![](https://github.com/MetalPetal/VideoIO/workflows/Swift/badge.svg)
Video Input/Output Utilities
## VideoComposition
Wraps around `AVMutableVideoComposition` with custom video compositor. A `BlockBasedVideoCompositor` is provided for convenience.
With [MetalPetal](https://github.com/MetalPetal/MetalPetal)
```Swift
let context = try! MTIContext(device: MTLCreateSystemDefaultDevice()!)
let handler = MTIAsyncVideoCompositionRequestHandler(context: context, tracks: asset.tracks(withMediaType: .video)) { request in
return FilterGraph.makeImage { output in
request.anySourceImage => filterA => filterB => output
}!
}
let composition = VideoComposition(propertiesOf: asset, compositionRequestHandler: handler.handle(request:))
let playerItem = AVPlayerItem(asset: asset)
playerItem.videoComposition = composition.makeAVVideoComposition()
player.replaceCurrentItem(with: playerItem)
player.play()
```Without MetalPetal
```Swift
let composition = VideoComposition(propertiesOf: asset, compositionRequestHandler: { request in
//Process video frame
})
let playerItem = AVPlayerItem(asset: asset)
playerItem.videoComposition = composition.makeAVVideoComposition()
player.replaceCurrentItem(with: playerItem)
player.play()
```## AssetExportSession
Export `AVAsset`s. With the ability to customize video/audio settings as well as `pause` / `resume`.
```Swift
var configuration = AssetExportSession.Configuration(fileType: .mp4, videoSettings: .h264(videoSize: videoComposition.renderSize), audioSettings: .aac(channels: 2, sampleRate: 44100, bitRate: 128 * 1000))
configuration.metadata = ...
configuration.videoComposition = ...
configuration.audioMix = ...
self.exporter = try! AssetExportSession(asset: asset, outputURL: outputURL, configuration: configuration)
exporter.export(progress: { p in
}, completion: { error in
//Done
})
```## PlayerVideoOutput
Output video buffers from `AVPlayer`.
```Swift
let player: AVPlayer = ...
let playerOutput = PlayerVideoOutput(player: player) { videoFrame in
//Got video frame
}
player.play()
```## MovieRecorder
Record video and audio.
## AudioQueueCaptureSession
Capture audio using `AudioQueue`.
## Camera
Simple audio/video capture.