我正在使用AVAssetWriterInput从用户那里获取一个mp3文件,并将其通过电子邮件发送(仅限DRM免费)。在使用PCM时,我让这个过程正常工作,但是当我尝试mp3、m4a或caf时,我要么得到一个不能工作的文件,要么得到空数据。我想这是由于我的输出设置造成的。未绘制数据的输出设置如下所示。我对改变这一切持开放态度。谢谢!
NSDictionary *outputSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[ NSNumber numberWithInt: kAudioFormatMPEG4AAC], AVFormatIDKey,
[ NSNumber numberWithInt: 1 ], AVNumberOfChannelsKey,
[ NSNumber numberWithFloat: 44100.0 ], AVSampleRateKey,
[ NSData dataWithBytes: &channelLayout length: sizeof( AudioChannelLayout ) ], AVChannelLayoutKey,
[ NSNumber numberWithInt: 64000 ], AVEncoderBitRateKey,
nil];发布于 2011-06-19 16:54:54
苹果没有提供编写mp3文件的应用程序接口,也许是因为mp3只是无头的数据包,简单地写出原始数据包就行了。
至于在m4a/caf容器中写出AAC数据,我不确定--但AVEncoderBitRateKey绝对不应该在那里,因为你没有编码任何东西--你只是在传递数据。那么,为什么不忘记AVAssetWriter,使用带有直通预设的AVAssetExportSession呢?
https://stackoverflow.com/questions/6392056
复制相似问题