2012-01-20 2 views
0

이 이미지를 QTMovie에 추가하려하지만 파일이 나타나지 않습니다. 나는 당신이 추가 한 후에는 프레임QTMovie가 파일에 쓰지 않습니다.

[tst updateMovieFile]; 

NSString *tempName = [NSString stringWithFormat:@"/Users/nathanmswan/aaaa.mov"]; 
tst = [[QTMovie alloc] initToWritableFile:tempName error:NULL]; 

같은 파일에 직접 동영상을 기록 할 수

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

속성을 함께 할 수있는 뭔가 또는 addImage:이 있다고 생각 이렇게하면 파일이 만들어지고 파일에 모든 내용이 쓰여진 다음 저장됩니다. writeToFile :은 필요하지 않습니다. 그러나 addImage : 메서드에서 사용되는 'dict'은 사용 전에 초기화되지 않은 것처럼 보입니다. addImage의 코덱을 참조해야합니다. 예 :

dict = [NSDictionary dictionaryWithObjectsAndKeys:@"mp4v", 
      QTAddImageCodecType, 
      [NSNumber numberWithLong:codecHighQuality], 
      QTAddImageCodecQuality, 
      nil]; 
관련 문제