Hi -
I'm trying to combine two .mp3s into a single .wav file using QTKit. It seems to be working, but the last few seconds of the second file are getting truncated. Any ideas?
- (IBAction)combineSelectedFilesAndOutputAsWAV {
QTMovie *movie = [QTMovie movieWithFile:fileOne error:NULL];
[movie setAttribute:[NSNumber numberWithBool:YES] forKey:QTMovieEditableAttribute];
QTMovie *segmentTwo = [QTMovie movieWithFile:fileTwo error:NULL];
QTTimeRange range = { .time = QTZeroTime, .duration = [segmentTwo duration] };
[segmentTwo setSelection:range];
[movie appendSelectionFromMovie:segmentTwo];
while([[movie attributeForKey:QTMovieLoadStateAttribute] longValue] != 100000L) {
//wait until QTMovieLoadStateComplete
}
NSDictionary *exportAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], QTMovieExport,
[NSNumber numberWithLong:kQTFileTypeWave], QTMovieExportType, nil];
NSString *outputFile = [NSString stringWithFormat:@"%@.wav", outputFilename];
NSString *filepath = [destinationDirectory stringByAppendingPathComponent:outputFile];
if (![movie writeToFile:filepath withAttributes:exportAttributes]) {
//ERROR
}
}
(Ignore the while loop waiting for QTMovieLoadStateComplete. I'll switch to using notifications in the future. But for now, it shouldn't matter...)