[英]How do I use AVAssetWriter to write correct WAV audio out in ios?
我正在使用AVAssetWriter在app temp文件夾中使用以下設置輸出wav文件:
NSDictionary* outputSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[ NSNumber numberWithInt: kAudioFormatMPEG4AAC], AVFormatIDKey,
[ NSNumber numberWithInt: 2 ], AVNumberOfChannelsKey,
[ NSNumber numberWithFloat: 44100.0 ], AVSampleRateKey,
[ NSData data ], AVChannelLayoutKey,
[ NSNumber numberWithInt: 64000 ], AVEncoderBitRateKey,
nil];
它輸出看似正常的45mb .wav文件,但應用無論如何都無法讀取它。 我懷疑文件頭已損壞,因為我在大膽中打開了.wav(接受它沒有問題)並再次使用.wav擴展名重新導出它。 導出的文件在應用程序中運行良好。
我還使用文本編輯器打開了兩個.wav文件以查看標題,它們有些不同。
任何線索?
您正在使用kAudioFormatMPEG4AAC
為AVFormatIDKey
時,你應該使用kAudioFormatLinearPCM
。 Wave文件是PCM格式,無法使用MPEG-4數據包導出。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.