我正在嘗試使用QTKit將圖像列表轉換爲Quicktime影片。我已經想出瞭如何去做所有的事情,除了將幀速率提高到29.97。通過其他論壇和資源,招好像是用這樣的:QTMovie at 29.97 with QTMakeTime
QTTime frameDuration = QTMakeTime(1001, 30000)
但是,使用這種方法,甚至是(1000,29970),我所有的努力仍處於30fps的製作影片。這個fps是使用Quicktime播放器時顯示的內容。
任何想法?有沒有其他的方式來設置整個電影創建後的幀頻?
下面是一些示例代碼:
NSDictionary *outputMovieAttribs = [NSDictionary dictionaryWithObjectsAndKeys:@"jpeg", QTAddImageCodecType, [NSNumber numberWithLong:codecHighQuality], QTAddImageCodecQuality, nil];
QTTime frameDuration = QTMakeTime(1001, 30000);
QTMovie *outputMovie = [[QTMovie alloc] initToWritableFile:@"/tmp/testing.mov" error:nil];
[outputMovie setAttribute:[NSNumber numberWithBool:YES] forKey:QTMovieEditableAttribute];
[outputMovie setAttribute:[NSNumber numberWithLong:30000] forKey:QTMovieTimeScaleAttribute];
if (!outputMovie) {
printf("ERROR: Chunk: Could not create movie object:\n");
} else {
int frameID = 0;
while (frameID < [framePaths count]) {
NSAutoreleasePool *readPool = [[NSAutoreleasePool alloc] init];
NSData *currFrameData = [NSData dataWithContentsOfFile:[framePaths objectAtIndex:frameID]];
NSImage *currFrame = [[NSImage alloc] initWithData:currFrameData];
if (currFrame) {
[outputMovie addImage:currFrame forDuration:frameDuration withAttributes:outputMovieAttribs];
[outputMovie updateMovieFile];
NSString *newDuration = QTStringFromTime([outputMovie duration]);
printf("new Duration: %s\n", [newDuration UTF8String]);
currFrame = nil;
} else {
printf("ERROR: Could not add image to movie");
}
frameID++;
[readPool drain];
}
}
NSString *outputDuration = QTStringFromTime([outputMovie duration]);
printf("output Duration: %s\n", [outputDuration UTF8String]);
完美無瑕,效果很棒! 感謝您的幫助! – bchapman 2012-02-01 19:53:31
非常歡迎! – guitarflow 2012-02-01 20:17:31