Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将iphone中录制的声音从一种格式转换为另一种格式,如wav转换为mp3_Iphone_Mp3_Wave_Audiotoolbox - Fatal编程技术网

将iphone中录制的声音从一种格式转换为另一种格式,如wav转换为mp3

将iphone中录制的声音从一种格式转换为另一种格式,如wav转换为mp3,iphone,mp3,wave,audiotoolbox,Iphone,Mp3,Wave,Audiotoolbox,我正在尝试录制一些音频并将其转换为其他声音格式。我正在使用AVAudioRecorder类进行录制,这些是我使用的录制设置 NSDictionary *recordSetting = [[NSMutableDictionary alloc] init]; [recordSetting setValue:[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey];//kAudioFormatMicrosoftGSM,

我正在尝试录制一些音频并将其转换为其他声音格式。我正在使用AVAudioRecorder类进行录制,这些是我使用的录制设置

 NSDictionary *recordSetting = [[NSMutableDictionary alloc] init];
 [recordSetting setValue:[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey];//kAudioFormatMicrosoftGSM,kAudioFormatLinearPCM
 [recordSetting setValue:[NSNumber numberWithFloat:8000] forKey:AVSampleRateKey]; 
 [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
 [recordSetting setValue :[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
 [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
 [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];
录音效果很好。现在我想把这个声音文件转换成mp3格式。我可以用AudioToolBox框架来做这件事吗。我试过这个

 AudioStreamBasicDescription sourceFormat,destinationFormat;
 //Setting up source Format setting..here wav
 sourceFormat.mSampleRate   = 8000.0;
 sourceFormat.mFormatID    = kAudioFormatLinearPCM;
 sourceFormat.mFormatFlags   = kAudioFormatFlagIsSignedInteger ;
 sourceFormat.mBytesPerPacket  = 4;
 sourceFormat.mFramesPerPacket  = 1;
 sourceFormat.mBytesPerFrame   = 4;
 sourceFormat.mChannelsPerFrame  = 2;
 sourceFormat.mBitsPerChannel  = 16;

 destinationFormat.mSampleRate  = 8000.0;
 destinationFormat.mFormatID   = kAudioFormatMPEGLayer3;
 destinationFormat.mFormatFlags  = 0;
 destinationFormat.mBytesPerPacket = 4;
 destinationFormat.mFramesPerPacket = 1;
 destinationFormat.mBytesPerFrame = 4;
 destinationFormat.mChannelsPerFrame = 2;
 destinationFormat.mBitsPerChannel = 16;

 OSStatus returnCode     =     AudioConverterNew(&sourceFormat,&destinationFormat,&converter);
 if (returnCode) {
    NSLog(@"error getting converter : %d",returnCode);
    return;
 }
函数AudioConverterNew()给了我错误kaudioconverterner\u FormatNotSupported('fmt')。我尝试了不同的mFormatID和mFormatFlag组合。但每当一个操作(源或目标)是mp3时,我就会得到这个错误。现在请帮我回答这些问题

  • 我们可以使用AudioToolbox框架吗 和转换声音的函数 在压缩和非压缩之间 压缩格式(目前我想要 在.wav和.mp3之间转换)。 在新的音频转换器中 他们在说什么 “在 线性PCM和压缩格式是 支持”。但事实并非如此 具体说哪一个压缩了 格式

  • 如果问题1的答案是“否” 那么我需要使用哪个框架呢 用于将声音转换为 上述格式

  • 与上述2项无关,但可以 有人给我一个链接吗 有关 不同的声音格式(wav、mp3、aac 等)及其数字 表示法(cpm、lpcm等) 我能理解它的用途 什么
  • 一些答案

  • 是的,您可以使用AudioToolbox框架转换声音,但.mp3格式除外。由于版权问题,mp3不能作为框架内的目标格式提供

  • 如果要转换为mp3,可能需要使用LAME库:

  • 下面是一个.mp3规范: 通过web搜索,您可以很容易地找到其他格式

  • 希望有帮助