3

i'm trying to process audio iOS.

When play audio in realtime, i can use AVAudioPlayer, and get audio power (dB) by function: averagePowerForChannel.

But there is a case where i need to get audio power at arbitrary time: In my Video editor tool:

  • When exporting video frame n1 at time t1, I want to get audio power at time t1 to draw a VU Meter in that video frame.
  • When exporting video frame n2 at time t2,...

I have think about some solutions but i seems not so convenient and fast:

  • Use AVAssetReaderTrackOutput seek to time (support in iOS >=8), then read CMSampleBuffer to get audio sample and calculate power.

  • Use AudioToolbox to seek file: ExtAudioFileSeek() and then read audio sample from that position and calculate power.

But it seems not so convenient, so is there another way (use CoreAudio, AudioQueue, AudioUnit,...) to get audio power at arbitrary time in iOS?

0 Answers0