开发者

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜