2013-04-09 148 views
1

我想將聲音錄製在我的iPhone應用程序中,但我只能以某種特定的格式錄製它。如何以mp3格式錄製 我已經搜索了很多,但找不到解決如何在iPhone中以mp3格式錄製聲音

我發現AVRecorder不會支持MP3錄音,即使有iTunes中許多應用程序,以記錄MP3格式

我怎樣才能做到這一點,請幫助me..thanks提前

+0

首先嚐試搜索Internet:http://stackoverflow.com/questions/10314510/how-to-record-audio-as-mp3-file-by-using-avaudiorecorder,http://stackoverflow.com/questions/ 10549023/iphone-app-recording-audio-in-mp3,http://stackoverflow.com/questions/4871940/how-to-record-an-audio-file-in-mp3-format,http:// stackoverflow。 com/questions/1005598 /正在尋找一種方式來編碼-iPhone- – CRDave 2013-04-09 10:45:52

+1

記錄的文件是.caf文件格式。錄製後必須將.caf轉換爲.mp3文件格式。 – Tirth 2013-04-09 10:53:38

+0

@iAmbitious如何將.caf轉換爲.mp3 – 2013-04-09 11:27:40

回答

2

Here是你的問題的解決方案。

此演示程序由apple開發,適用於mp3格式的音頻錄製。我已經開發了一個應用程序(BRL App)使用此演示。

這是蘋果開發人員開發的非常有用的演示。

+0

與帖子鏈接有問題,他們有時可以刪除:'(但谷歌不知道 – TommyBs 2016-07-08 14:29:09

0

的NSString * path = [[NSBundle mainBundle] pathForResource:@ \「mp3Header \」ofType:@ \「mp3 \」];

NSMutableData * audioData = [[NSMutableData alloc] initWithContentsOfFile:path];

int samples = 22050;

uint8_t dataToRecord [samples];

int x;

爲(X = 0; X <樣本; X ++){

// populate the \"dataToRecord\" array with audio data. // 

}

[audioData對appendBytes:(常量無效*)dataToRecord長度:樣品];

// Get path to documents folder and set a file name // 

[audioData writeToFile:pathToFile atomically:YES];