FDWaveformView
FDWaveformView copied to clipboard
iOS Example: FDWaveformView failed to load AVAssetTrack for ogg file
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:
Is ogg currently not supported?
Thanks in advance.
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.
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
}```
Yes, CAF is definitely supported.
That is a good link. If there is something directly published by Apple that would be preferred.
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
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.