2014-09-26 114 views
0

我使用Tony's tutorial製作了Multipeer Audio Streaming應用程序。 但我只能用128kbps比特率播放.mp3。 所以我需要將192kbps或更高比特率的.mp3降低到128kbps。 我發現了一個類似的解決方案[here],但它是用於將mp3編碼爲視頻。如何降低iOS中的mp3比特率?

請幫助我如何降低比特率。

+0

看到我的編輯,我添加了比特率鍵 – l0gg3r 2014-09-26 08:16:20

+0

有什麼好消息嗎? – l0gg3r 2014-09-26 09:09:25

+0

有一個例外。我在你的回答中評論。 – Janos 2014-09-26 09:11:29

回答

0
AVAssetReaderTrackOutput *assetOutput = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:asset.tracks[0] outputSettings:nil]; 

你應該在服務器端提供outputSettings:(手機,流音頻)

因此,它應該是這樣的。

NSDictionary *settings = @{ 
    AVEncoderBitRateKey : @128000, 
    AVFormatIDKey : @(kAudioFormatAppleIMA4), 
    AVNumberOfChannelsKey : @2, 
    AVLinearPCMBitDepthKey : @16, 
    AVLinearPCMIsBigEndianKey : @NO, 
    AVLinearPCMIsFloatKey : @NO 
}; 
AVAssetReaderTrackOutput *assetOutput = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:asset.tracks[0] outputSettings:settings]; 
+0

我不使用流媒體服務器。我使用iphone作爲音頻廣播器,另一個iphone作爲音頻監聽器。當我在廣播公司以128kbps比特率播放音樂.mp3時,我可以在聽衆上播放音樂。但超過192kbps的比特率,沒有聲音。所以我需要將比特率降低到128kbps。 – Janos 2014-09-26 08:07:35

+0

我將編輯我的文章 – l0gg3r 2014-09-26 08:12:26

+0

有一個這樣的例外; 2014-09-26 16:31:18.039 MultipeerAudioStreamer [10376:60b] ***因未捕獲異常'NSInvalidArgumentException'而終止應用,原因:'*** - [AVAssetReaderTrackOutput initWithTrack:outputSettings:] AVAudioSettings字典必須包含AVFormatIDKey' – Janos 2014-09-26 08:42:13