私が現在コーディングしているココア アプリケーションでは、Quartz Composer レンダラー (NSImage オブジェクト) からスナップショット イメージを取得しており、addImage を使用して 720*480 サイズ、25 fps、および H264 コーデックで QTMovie にエンコードしたいと考えています。 : 方法。対応するコードは次のとおりです。
qRenderer = [[QCRenderer alloc] initOffScreenWithSize:NSMakeSize(720,480) colorSpace:CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB) composition:[QCComposition compositionWithFile:qcPatchPath]]; // define an "offscreen" Quartz composition renderer with the right image size
imageAttrs = [NSDictionary dictionaryWithObjectsAndKeys: @"avc1", // use the H264 codec
QTAddImageCodecType, nil];
qtMovie = [[QTMovie alloc] initToWritableFile: outputVideoFile error:NULL]; // initialize the output QT movie object
long fps = 25;
frameNum = 0;
NSTimeInterval renderingTime = 0;
NSTimeInterval frameInc = (1./fps);
NSTimeInterval myMovieDuration = 70;
NSImage * myImage;
while (renderingTime <= myMovieDuration){
if(![qRenderer renderAtTime: renderingTime arguments:NULL])
NSLog(@"Rendering failed at time %.3fs", renderingTime);
myImage = [qRenderer snapshotImage];
[qtMovie addImage:myImage forDuration: QTMakeTimeWithTimeInterval(frameInc) withAttributes:imageAttrs];
[myImage release];
frameNum ++;
renderingTime = frameNum * frameInc;
}
[qtMovie updateMovieFile];
[qRenderer release];
[qtMovie release];
それは機能しますが、私のアプリケーションは私の新しい MacBook Pro でそれをリアルタイムで行うことはできませんが、QuickTime Broadcaster は H264 でリアルタイムで画像をエンコードでき、同じコンピューターで私が使用するものよりもさらに高い品質であることがわかっています。 .
なぜ ?ここで何が問題なのですか?これはハードウェア管理の問題 (マルチコア スレッディング、GPU など) ですか、それとも何か不足していますか? 序文として、私は Apple 開発の世界で、Objective-C、cocoa、X コード、Quicktime、Quartz Composer ライブラリなどの新人 (2 週間の練習) であることを前置きさせてください。
助けてくれてありがとう