Record audio iOS

2019-01-23 07:25发布

How does one record audio using iOS? Not the input recording from the microphone, but I want to be able to capture/record the current playing audio within my app?

So, e.g. I start a recording session, and any sound that plays within my app only, I want to record it to a file?

I have done research on this but I am confused with what to use as it looks like mixing audio frameworks can cause problems?

I just want to be able to capture and save the audio playing within my application.

4条回答
霸刀☆藐视天下
2楼-- · 2019-01-23 07:45

Well if you're looking to just record the audio that YOUR app produces, then yes this is very much possible.

What isn't possible, is recording all audio that is output through the speaker. (EDIT: I just want to clarify that there is no way to record audio output produced by other applications. You can only record the audio samples that YOU produce).

If you want to record your app's audio output, you must use the remote io audio unit (http://atastypixel.com/blog/using-remoteio-audio-unit/).

All you would really need to do is copy the playback buffer after you fill it.

ex)

 memcpy(void *dest, ioData->mBuffers[0].mData, int amount_of_bytes);
查看更多
该账号已被封号
3楼-- · 2019-01-23 07:52

This is possible by wrapping a Core Audio public utility file CAAudioUnitOutputCapturer http://developer.apple.com/library/mac/#samplecode/CoreAudioUtilityClasses/Introduction/Intro.html

See my reply in this question for the wrapper classes. Properly use Objective C++

查看更多
唯我独甜
4楼-- · 2019-01-23 07:55

Check out the MixerHostAudio sample application from Apple. Its a great way to start learning about Audio Units. Once you have an grasp of that, there are many tutorials online that talk about adding recording.

查看更多
唯我独甜
5楼-- · 2019-01-23 07:59

There is no public API for capturing or recording all generic audio output from an iOS app.

查看更多
登录 后发表回答