开发者

Easy way to decode mp3 into wav programmatically?

开发者 https://www.devze.com 2023-02-02 06:27 出处:网络
Is there an easy way to convert mp3s to wavs on a mac (p开发者_JS百科rogrammatically) with (maybe with QTKit)?

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

精彩评论

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