A Swift library for converting to and from opus/ogg format
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-05-05 15:21:44 +03:00
.github/ISSUE_TEMPLATE Initial commit 2022-06-02 17:09:34 +01:00
Sample fix crash on arm64 due to invalid buffer deallocation and add sample app for running on the device. 2022-07-14 15:06:30 +01:00
Sample.xcworkspace fix crash on arm64 due to invalid buffer deallocation and add sample app for running on the device. 2022-07-14 15:06:30 +01:00
Sources fix leak of stream_state internal memory 2026-05-05 15:21:44 +03:00
Tests/EncoderDecoderTests use XCTFail 2022-09-14 09:12:33 +01:00
.gitignore update copyright, readme and gitignore 2022-06-08 15:52:31 +01:00
LICENCE Create LICENCE 2022-06-02 17:12:58 +01:00
Package.swift It's Sources/SwiftOgg not Sources/SwiftOGG (#16) 2024-05-01 09:58:21 +01:00
README.md update repos in readme 2022-07-13 15:04:26 +01:00
SECURITY.md Point to Element security@ address and policy 2024-01-30 14:34:22 +02:00

swift-ogg

This library provides a very simple API to convert between opus/ogg and MPEG4AAC/m4a files. It uses opus's libopus libogg to convert between opus/ogg and linear PCM audio data and native iOS apis to convert between PCM and MPEG4AAC/m4a(but could be very easily adapted to use any other codec/container supported by iOS). Apple's recording and playback APIs from AVFoundation can then be used quite simply with a codec/container pair that iOS natively supports (MPEG4AAC/m4a in this case).

Usage

    let src:URL = ...
    let dest:URL = ...
    let dest2:URL = ...
    do {
        // Convert to OGG
        try OGGConverter.convertM4aFileToOpusOGG(src: src, dest: dest)
        // And back to M4a
        try OGGConverter.convertOpusOGGToM4aFile(src: dest, dest: dest2)
    } catch {
        // handle error
    }

Licence

Portions of the swift-ogg library contain code derived from watson-developer-cloud/swift-sdk under the Apache License 2.0

This project makes use of opus-swift and ogg-swift which package the source code of libopus and libogg as platform independent XCFrameworks. These two projects are under the MIT licence while the underlying libopus and libogg library source themselves are included under the BSD Licence described here