How to convert WAV file to M4A?

Is there a way to convert my recorded .WAV file to a .M4A file in iOS?

And also I need to convert the .M4A file to a .WAV file.

I tried with Audio Queue Services, but I cannot do this.

+5
source share
2 answers

This entry: From the iPod library to PCM samples, in much smaller steps than before it was necessary to describe how to download a file from the users ipod library and write it to the file system as a linear pcm (wav) file.

, , , 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, .

- ffmpeg lib , , .

+3

All Articles