简体   繁体   中英

Encode PCMBuffer to Ogg with Opus in iOS 8

I need to encode raw audio into ogg packets with opus codec.

I get the raw audio like that:

    input.installTapOnBus(0, bufferSize: 2048, format: input.inputFormatForBus(0)) { (buffer: AVAudioPCMBuffer!, time: AVAudioTime!) -> Void in

        // Encode buffer to Ogg
    }

I have Ogg.framework and libopus.a in my project. I don't seem to understand the documentation how to actually use Opus with Ogg. And I didn't find any example that replicates what I need.

Any help appreciated!

There are at least two options:

  1. Create some wrapper for opusenc library for encoding PCM in Ogg/Opus. This library is written in pure C but well structered and easy to use. Just look at the example "examples/opusenc_example.c"
  2. Hijack some code from watson-developer-cloud/swift-sdk it contains decoder and encoder for OGG/OPUS based on libopus and ogg .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM