2012-01-20 12 views
0

これらのイメージをQTMovieに追加しようとしていますが、ファイルが表示されません。私はそれはあなたがフレームQTMovieがファイルに書き込まない

[tst updateMovieFile]; 

を追加した後にあなたがこの

のようにファイルに直接
NSString *tempName = [NSString stringWithFormat:@"/Users/nathanmswan/aaaa.mov"]; 
tst = [[QTMovie alloc] initToWritableFile:tempName error:NULL]; 

を映画を書くことができる属性やaddImage:

NSTimeInterval t; 
QTGetTimeInterval(frameInterval, &t); 
NSLog(@"%f", t); // outputs 0.0333333 


// --- initializes the movie --- 
NSError *error = nil; 

NSDictionary *at = [NSDictionary dictionaryWithObjectsAndKeys: 
        [NSNumber numberWithBool:YES], QTMovieEditableAttribute, 
        nil]; 

QTMovie *tst = [QTMovie movieWithAttributes:at error:&error]; 

if (error) { 
    NSLog(@"%@", [error localizedDescription]); // outputs (null) 
} 


// --- initializes the images --- 
NSImage *i1 = [[NSImage alloc] 
       initWithContentsOfFile:@"~/agimgs/1.tiff"]; 
NSImage *i2 = [[NSImage alloc] 
       initWithContentsOfFile:@"~/agimgs/110.tiff"]; 
NSImage *i3 = [[NSImage alloc] 
       initWithContentsOfFile:@"~/agimgs/130.tiff"]; 

// --- adds the images --- 
for (int j=0; j<50; j++) { 
    [tst addImage:i1 forDuration:frameInterval withAttributes:dict]; 
    [tst addImage:i2 forDuration:frameInterval withAttributes:dict]; 
    [tst addImage:i3 forDuration:frameInterval withAttributes:dict]; 
} 

// --- (supposed to) output the movie --- 
dict = [NSDictionary dictionaryWithObjectsAndKeys: 
     [NSNumber numberWithBool:YES], QTMovieExport, 
     nil]; 

BOOL worked = [tst writeToFile:@"/Users/nathanmswan/aaaa.mov" withAttributes:dict error:&error]; 
if (!worked) { 
    NSLog(@"%@", [error localizedDescription]); // outputs nothing 
} 

NSLog(@"done with aaaa.mov"); 

答えて

1

とは何かを持っていると思いますこれにより、ファイルが作成され、すべてがファイルに書き込まれ、保存されます。 writeToFile:は必要ありません。しかし、addImage:メソッドで使用される 'dict'は、使用前に初期化されていないようです... addImageのコーデックを参照する必要があります。たとえば、

dict = [NSDictionary dictionaryWithObjectsAndKeys:@"mp4v", 
      QTAddImageCodecType, 
      [NSNumber numberWithLong:codecHighQuality], 
      QTAddImageCodecQuality, 
      nil]; 
関連する問題