【问题标题】:Audio which is recorded in iOS programmatically could not be playable in Windows以编程方式在 iOS 中录制的音频无法在 Windows 中播放
【发布时间】:2014-11-13 08:38:14
【问题描述】:

场景: 我正在开发的应用程序我想录制语音备忘录并将它们发送到 Windows 客户端。在 iOS 中录制音频并没有那么难,但录制的文件(在我的情况下是以 .mp3 的形式)could not be playable in Windows 但相同的文件could be easily playable in Mac

我强烈怀疑我在以下代码中使用的录音设置,

_audioRecorder = [[AVAudioRecorder alloc] initWithURL:audioFileURL settings:_recordingSettings error:&error];

我使用的设置是,

_recordingSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                         [NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey,
                         [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey,
                         [NSNumber numberWithInt:16], AVEncoderBitRateKey,
                         [NSNumber numberWithInt: 2], AVNumberOfChannelsKey,
                         [NSNumber numberWithFloat:44100.0], AVSampleRateKey,
                      nil];

我已经尝试过各种AVFormatIDKeys比如

kAudioFormatLinearPCM    - .lpcm
kAudioFormatMPEG4AAC     - .acc
kAudioFormatMPEGLayer3   - .mp3

但没有收获。

感谢您的帮助。如果不可能,我需要解释原因!

【问题讨论】:

标签: ios objective-c audio audio-recording


【解决方案1】:

经过一些随机尝试后,我已经通过设置管理了自己,

_recordingSettings = [[NSDictionary alloc] initWithObjectsAndKeys:
                         [NSNumber numberWithInt:kAudioFormatLinearPCM],AVFormatIDKey,
                         [NSNumber numberWithInt:16],AVLinearPCMBitDepthKey,
                         [NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey,
                         [NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,
                         [NSNumber numberWithBool:NO],AVLinearPCMIsNonInterleaved,
                         [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey,
                         [NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
                         [NSNumber numberWithFloat:2000.0], AVSampleRateKey,
                     nil];

重要提示:文件名应为“someName.wav”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多