2012-07-24 83 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.请求作者进行编码。