2012-07-24 98 views
1

我想從沒有音頻文件的png圖像創建視頻。iPhone:從圖像創建視頻

我已經實現了下面的代碼,但我的圖像運行不順暢。

- (void)viewDidLoad 
{ 
    totalImages = 121; 
    counter=1; 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
} 
-(void)viewDidAppear:(BOOL)animated 
{ 
    levelTimer = [NSTimer scheduledTimerWithTimeInterval:0.40 target: self selector: @selector(levelTimerCallback:) userInfo: nil repeats: YES]; 
} 

- (void)levelTimerCallback:(NSTimer *)timer 
{ 

    if(counter <= totalImages) 
    { 
     NSString *fileName = [NSString stringWithFormat:@"image_iphone_%d",counter]; 
     NSLog(@"filenameEasy:%@",fileName); 
     NSString *fileLocation = [[NSBundle mainBundle] pathForResource:fileName ofType:@"png"]; 

     UIImage *imageName = [[UIImage alloc] initWithContentsOfFile:fileLocation]; 
     imgV.image = imageName; 
     counter++; 
     NSLog(@"counter:%d",counter); 
     [imageName release]; 
     [self viewDidAppear:NO]; 
    } 

} 

如果您有任何想法請分享它。 thanx提前。

回答

4

你可以在這方面還有

Make movie file with picture Array and song file, using AVAsset

一看這將是一個有點混亂,如果你以前沒有嘗試AVFoundation。

它的概念是這樣的:
1.設置一個assetwriter(幫助寫出視頻)。
2.告訴作者你想輸入什麼音軌(添加視頻和音頻writerInput)
3.如果一切正常,請嘗試將圖像放入視頻軌跡
4.請求作者進行編碼。