Swiftpack.co -  MetalPetal/VideoIO as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
MetalPetal/VideoIO
Video Input/Output Utilities
.package(url: "https://github.com/MetalPetal/VideoIO.git", from: "2.1.0")

VideoIO

Video Input/Output Utilities

VideoComposition

Wraps around AVMutableVideoComposition with custom video compositor. A BlockBasedVideoCompositor is provided for convenience.

With MetalPetal

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

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 AVAssets. With the ability to customize video/audio settings as well as pause / resume.

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.

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.

GitHub

link
Stars: 61
Last commit: 2 days ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

2.1.0
2 days ago

Add macCatalyst support. d3bb6590c0325f29323fd89652d77563f51d56cf

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API