可在 Windows Media Player 上播放的 iPhone 压缩音频格式
我必须在 iPhone 上录制音频,然后在 Windows Media Player 上播放,不使用非标准编解码器;也就是说,不使用 WMP 中未附带的编解码器。 (公司要求。)音频必须以 base-64 传输到服务器,因此我需要使音频大小尽可能小。即使在 8Kb 录制频率下,AIFF 文件也会占用大量空间。我似乎找不到 WMP 可以吞下的压缩 AIFF 格式。
I have to record audio on an iPhone that will play back on Windows Media Player, using no non-standard codecs; that is, using no codecs that don't already ship with WMP. (Corporate requirement.) The audio has to go base-64 to a server, so I need to get the audio size as small as possible. Even at 8Kb recording frequency, AIFF files take ginormous amounts of space. I can't seem to find a compressed AIFF format that WMP will swallow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好的选择是使用 ulaw 或 alaw 压缩编写 WAV 文件(
AudioStreamBasicDescription
的mFormatId
将为kAudioFormatULaw
或kAudioFormatALaw
>. 测试一下哪一个为您的应用程序提供了最小的文件大小。下面是一些设置 ExtAudioFile 实例来编写 ulaw 的代码:
希望有所帮助
--- 添加 ---
以下是对 SpeakHere 示例代码的修改。获取 ulaw 压缩:
SpeakHereController.mm:116
SpeakHereController.mm:158
AQRecorder.mm:192
AQRecorder.mm:215
Best bet is to write WAV files with ulaw or alaw compression (the
mFormatId
of yourAudioStreamBasicDescription
would bekAudioFormatULaw
orkAudioFormatALaw
. Test to see which one gives you the smallest file sizes for your application.Here's some code to set up an ExtAudioFile instance to write ulaw:
Hope that helps.
--- ADDED ---
Here are modifications to the SpeakHere sample code to get ulaw compression:
SpeakHereController.mm:116
SpeakHereController.mm:158
AQRecorder.mm:192
AQRecorder.mm:215
虽然距离上一篇文章已经很长时间了,但我发现 user196004 问题的答案是无法保存到临时文件夹以外的文件夹。
AudioFileCreateWithURL 将 CFURLRef 作为输入。如果使用 CFURLCreateWithString 创建 url,并且目标文件夹中有任何空格,则 url 创建将失败(null)。
解决方案是转义字符串。
CFStringRef fileNameEscaped = CFURLCreateStringByAddingPercentEscapes( NULL, fileName, NULL, NULL, kCFStringEncodingUTF8 );
Although a long time since the last post, I found the answer to the problem user196004 was having not being able to save to a folder OTHER than the temporary folder.
AudioFileCreateWithURL takes a CFURLRef as input. If the url is created using CFURLCreateWithString, and the destination folder has any spaces in it, the creation of the url will fail (null).
The solution is to escape the string.
CFStringRef fileNameEscaped = CFURLCreateStringByAddingPercentEscapes( NULL, fileName, NULL, NULL, kCFStringEncodingUTF8 );