FDWaveformView icon indicating copy to clipboard operation
FDWaveformView copied to clipboard

iOS Example: FDWaveformView failed to load AVAssetTrack for ogg file

Open Dario-Gasquez opened this issue 3 years ago • 4 comments

Hi,

I tried the sample iOS app, it works with the .mp3 and .aac sample files, but when I try connecting and loading the ogg file it gives me the following error: FDWaveformView failed to load AVAssetTrack

An additional screenshot showing the change made to load the ogg file and the place where the error occurs: LoadOGG-error

Is ogg currently not supported?

Thanks in advance.

Dario-Gasquez avatar Aug 24 '21 15:08 Dario-Gasquez

I think the problem is that certain Apple devices / operating system versions support OGG and some don't. And of course this is different with simulator and real device.


I forget which is supported or not. And this is probably not a bug with the functionality of FDWaveformView. But we should find this authoritative link that describes which codecs Apple supports on which devices/OS/simulators and include that in documentation.

fulldecent avatar Aug 25 '21 01:08 fulldecent

Thanks for the quick answer. According to this wiki page, ogg (including opus) is supported since iOS 11 but as a Core Audio Format (.caf) container: https://en.wikipedia.org/wiki/Opus_%28audio_format%29#Operating_system_support

I successfully tested this with FDWaveformView by converting an .ogg(opus) file to .caf like this:

ffmpeg -i short-heartbeat.ogg -c:a copy short-heartbeat.caf

and then adding and using the resulting file with this code:

    @IBAction func doLoadCAF() {
        let thisBundle = Bundle(for: type(of: self))
        let url = thisBundle.url(forResource: "short-heartbeat", withExtension: "caf")
        waveform.audioURL = url
    }```

Dario-Gasquez avatar Aug 25 '21 13:08 Dario-Gasquez

Yes, CAF is definitely supported.

That is a good link. If there is something directly published by Apple that would be preferred.

fulldecent avatar Aug 25 '21 15:08 fulldecent

Although probably still not ideal, there are a couple of sources from Apple:

  • This What's New in Audio video fragment from WWDC217 : https://developer.apple.com/videos/play/wwdc2017/501/?time=2735

where they say:

..and for Opus, we have the codec, and the file I/O support using the code audio format container.

  • This constant added coincidentally in iOS 11: https://developer.apple.com/documentation/coreaudiotypes/1572096-audio_data_format_identifiers/kaudioformatopus

Dario-Gasquez avatar Aug 26 '21 17:08 Dario-Gasquez

The example app is updated now. https://github.com/fulldecent/FDWaveformView/blob/f470d434969778ede228b8041c6679bc8ae4f4e3/Example/Sources/ContentView.swift

I still see that simulator does not support OGG but real devices do.

fulldecent avatar Mar 28 '24 03:03 fulldecent