Edge Media is a Swift package that provides support for capturing video and audio data, and converting them to a variety of formats.
OS Support Edge-Media currently only supports Linux using the video4linux APIs.
import EdgeMedia
let devices = try await VideoDevice.listDevices()
guard let device = devices.first else {
throw Error("No video devices found")
}
// Capture an image, specifying the format type
let jpeg = try await device.capture(
width: 640,
height: 480,
format: JPEGImage.self
)
let jpegBytes = try jpeg.encoded(compression: 0.8).bytes