如何在iPhone上录制AMR音频格式? [英] How can I record AMR audio format on the iPhone?

查看:479
本文介绍了如何在iPhone上录制AMR音频格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

录音机不需要未压缩的线性PCM音频。压缩 AMR 会好起来的。用于录制音频的iPhone框架非常简单,但我找到的用于设置音频格式(来自Apple)的唯一示例使用LinearPCM。我已经尝试了各种其他值的组合,但似乎无法获得任何工作。

A voice recorder doesn't need uncompressed Linear PCM audio. Compressed AMR would do fine. The iPhone framework built for recording audio is simple enough, but the only examples I've found for setting up the audio format (which come from Apple) use LinearPCM. I've tried various other combinations of values, but can't seem to get anything to work.

是否有人有任何实际记录的代码 AMR

Does anybody have any code that actually records AMR?

编辑:
AMR格式是设置数据类型的选项之一,但其他选项(数据包大小,帧大小等)似乎不匹配无论我把它们设置为什么。

The AMR format is one of the options for setting the data type, but the other options (packet size, frame size, etc.) don't seem to match up no matter what I set them to.

编辑:以下是我对PCM版本的看法:

Here's what I have for the PCM version:

/*
 If we want to use AMR instead of PCM:
 AMR Format:
 Sampling Frequency: 8 kHz/13-bit (160 samples for 20 ms frames), filtered to 200-3400 Hz
 eight source codecs :  12.2, 1.2, 7.95, 7.40, 6.70, 5.90, 5.15, 4.75 kbit/s
 generated frame length: 244, 204,  159,  148,  134,  118,  103,   95 bits per frame
 */
format->mFormatID = kAudioFormatLinearPCM;
format->mSampleRate = 8000.0;    //8 kHz
format->mFramesPerPacket = 1;    //1 frame per packet
format->mChannelsPerFrame = 1;    //Mono
format->mBytesPerFrame = 2;        //8/bits per frame (round up)
format->mBytesPerPacket = 2;    //Same as bytes per frame
format->mBitsPerChannel = 16;    //16-bit audio
format->mReserved = 0;            //always 0
format->mFormatFlags = kLinearPCMFormatFlagIsBigEndian |
                       kLinearPCMFormatFlagIsSignedInteger |
                       kLinearPCMFormatFlagIsPacked;


推荐答案

AMR编解码器不支持编码/录制iPhone虽然支持播放:这就是kAudioFormatAMR常量存在的原因。

AMR codec is NOT supported for encoding/recording on the iPhone, albeit it is supported for playback: this is the reason the kAudioFormatAMR constant exists.

官方api 表示支持的编码格式为:

Official api says that supported encoding formats are:


  • ALAC (Apple Lossless)〜> kAudioFormatAppleLossless

  • iLBC (互联网低比特率编解码器,用于语音)〜> kAudioFormatiLBC

  • IMA / ADPCM (IMA4)〜> kAudioFormatAppleIMA4

  • 线性PCM 〜> kAudioFormatLinearPCM

  • μ-law 〜> kAudioFormatULaw

  • a-law 〜> kAudioFormatALaw

  • ALAC (Apple Lossless) ~> kAudioFormatAppleLossless
  • iLBC (internet Low Bitrate Codec, for speech) ~> kAudioFormatiLBC
  • IMA/ADPCM (IMA4) ~> kAudioFormatAppleIMA4
  • linear PCM ~> kAudioFormatLinearPCM
  • µ-law ~> kAudioFormatULaw
  • a-law ~> kAudioFormatALaw

您可以尝试使用其中一种格式或使用开源AMR编码器 goldenmean 暗示。

You may try one of these formats or use an open source AMR encoder as goldenmean suggests.

编辑:更新了官方API链接

edit: Updated Official api link

这篇关于如何在iPhone上录制AMR音频格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆