繁体   English   中英

在Windows中无法以编程方式在iOS中录制的音频无法播放

[英]Audio which is recorded in iOS programmatically could not be playable in Windows

场景:我正在使用的应用程序应该是将语音备忘录记录下来并将其发送到Windows客户端。 在iOS中录制音频并不难,但是录制的文件(在我的情况下为.mp3格式) could not be playable in Windowscould 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];

我已经尝试过各种AVFormatIDKey例如

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

但没有收获。

感谢您的帮助。 万一不可能,我需要解释为什么!

经过一些随机尝试后,我用设置来管理自己,

_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”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM