我正在使用 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];