Giter Club home page Giter Club logo

swift-ogg's Introduction

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

swift-ogg's People

Contributors

cog1to avatar davidegirardi avatar langleyd avatar vvit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swift-ogg's Issues

The library is making assumptions about the source file format.

Describe the bug
As described in element-hq/element-ios#6603, OGGConverter and OGGDecoder make assumptions about the format of the file, in particular that the file is mono. This can result in incorrect decoding and playback when a user tries to play an opus file that wasn't sent using the voice message functionality.

To Reproduce
See the issue in Element iOS

Expected behavior
The library should determine the format of the audio decode from the file rather than having this hard-coded.

Smartphone (please complete the following information):
iPhone 12 on iOS 15.6.1 running Element 1.8.27

let src = Bundle.main.url(forResource: "VoiceRecordingWeb", withExtension: "m4a")!

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Launch time crash of a distributed Mac version

Describe the bug
The native Mac app crashes if launched from distribution version.

To Reproduce
Steps to reproduce the behavior:

  1. Add Mac (AppKit) to supported destinations (Project > General > Add Mac)
  2. Archive the app and tap Distribute
  3. Choose either Custom > Development, Debugging or TestFlight method
  4. Choose valid code signing method
  5. Export the app
  6. Launch it and observe the crash

Expected behavior
The app shouldn't crash on launch

Crash Log

Process:               Sample [91091]
Path:                  /Users/USER/Downloads/*/Sample.app/Contents/MacOS/Sample
Identifier:            vector.im.Sample
Version:               1.0 (1)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2024-03-06 12:32:18.0689 +0200
OS Version:            macOS 14.3.1 (23D60)
Report Version:        12
Anonymous UUID:        7DEBD1ED-CD01-D593-760B-948571F5CC78

Sleep/Wake UUID:       9D950E35-C16E-4A15-9AAE-2A4E0093ADDD

Time Awake Since Boot: 1100000 seconds
Time Since Wake:       1793 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Termination Reason:    Namespace DYLD, Code 1 Library missing
Library not loaded: @rpath/YbridOpus.framework/Versions/A/YbridOpus
Referenced from: <27A979C0-B703-3395-8C01-747CE90CBFC3> /Users/USER/Downloads/*/Sample.app/Contents/MacOS/Sample
Reason: tried: '/Users/user/Downloads/Sample (iOS) 2024-03-06 12-32-10/Sample.app/Contents/MacOS/Frameworks/YbridOpus.framework/Versions/A/YbridOpus' (no such file), '/Users/user/Downloads/Sample (iOS) 2024-03-06 12-32-10/Sample.app/Contents/MacOS/Frameworks/YbridOpus.framework/Versions/A/YbridOpus' (no such file)
(terminated at launch; ignore backtrace)

Desktop:

  • OS: macOS 14.3.1 (23D60)
  • Version ARM-64 (Native)

Additional:
If we choose Release scheme and launch from Xcode - works fine.
When we observe the result app package both frameworks are there in the Frameworks dir.

Crashes when I use my audio.m4a file replace VoiceRecordingWeb.m4a https://github.com/FSilver/Resource/blob/main/audio.m4a

  1. func testConversionRoundTrip() {
    let src = Bundle.main.url(forResource: "VoiceRecordingWeb", withExtension: "m4a")!

func testConversionRoundTrip() {
let src = Bundle.main.url(forResource: "audio", withExtension: "m4a")!

  1. creashed
    encoder = opus_encoder_create(opusRate, pcmChannels, application.rawValue, &status)
    OGGEncoder.swift:80: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

  2. AVAudioRecorder
    [
    AVFormatIDKey: NSNumber(value: kAudioFormatMPEG4AAC),
    AVNumberOfChannelsKey: 1,
    AVEncoderAudioQualityKey : AVAudioQuality.low.rawValue,
    AVLinearPCMBitDepthKey : 16,
    AVSampleRateKey : 44100.0
    ]
    use this setting to create audio.m4a
    文件地址 https://github.com/FSilver/Resource/blob/main/audio.m4a

how to custom sampleRate?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.