Easy way to decode mp3 into wav programmatically?
Is there an easy way to convert mp3s to wavs on a mac (p开发者_JS百科rogrammatically) with (maybe with QTKit)? I've seen the SoundConvert example but to be honest I just don't understand it :P I need it to pass it to libofa for audio fingerprinting...
I found it! I leave it here, somebody might find it useful.
NSError *error = nil;
NSString *inputFile = [NSString stringWithFormat:@"./in.mp3"];
NSString *outputFile = [NSString stringWithFormat:@"./out.wav"];
QTMovie *movie = [QTMovie movieWithFile:inputFile error:&error];
if (error) {
#warning handle errors
}
NSDictionary *exportAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], QTMovieExport,
[NSNumber numberWithLong:kQTFileTypeWave], QTMovieExportType, nil];
if (![movie writeToFile:outputFile withAttributes:exportAttributes]) {
#warning handle errors
}
精彩评论