5

録音した .WAV ファイルを iOS で .M4A ファイルに変換する方法はありますか?

また、.M4A ファイルを .WAV ファイルに変換する必要があります。

Audio Queue Services を試しましたが、できません。

4

2 に答える 2

3

この投稿: iPod ライブラリから PCM サンプルへ、以前よりもはるかに少ない手順で、ユーザーの iPod ライブラリからファイルをロードし、それをリニア pcm (wav) ファイルとしてファイル システムに書き込む方法について説明します。

代わりに、ファイル システムからファイルをロードするためにコードに加える必要がある変更は、アセットの場所を記述する NSURL にあると思います。

-(IBAction) convertTapped: (id) sender {
// set up an AVAssetReader to read from the iPod Library
NSURL *assetURL = [[NSURL alloc]  initFileURLWithPath:@"your_m4a.m4a"];
AVURLAsset *songAsset =
    [AVURLAsset URLAssetWithURL:assetURL options:nil];

NSError *assetError = nil;
AVAssetReader *assetReader =
    [[AVAssetReader assetReaderWithAsset:songAsset
           error:&assetError]
      retain];
if (assetError) {
    NSLog (@"error: %@", assetError);
    return;
}

反対方向に進む場合は、出力側のフォーマットを変更する必要があります。

NSDictionary *outputSettings =[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kAudioFormatLinearPCM], AVFormatIDKey,
[NSNumber numberWithFloat:44100.0], AVSampleRateKey,
[NSNumber numberWithInt:2], AVNumberOfChannelsKey,
[NSData dataWithBytes:&channelLayout length:sizeof(AudioChannelLayout)],
    AVChannelLayoutKey,
[NSNumber numberWithInt:16], AVLinearPCMBitDepthKey,
[NSNumber numberWithBool:NO], AVLinearPCMIsNonInterleaved,
[NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,
[NSNumber numberWithBool:NO], AVLinearPCMIsBigEndianKey,
nil];

ここで m4a を使用する場合の正確な設定はわかりませんが、これでさらに近づくはずです。

もう1つのオプションは、ffmpeg libにロードしてそこですべての変換を行うことですが、それはあなたが望むものとは異なるようです.

于 2011-02-08T15:49:59.340 に答える
0

TPAACAudioConverterは正常に動作します

于 2011-09-08T19:08:54.620 に答える