简体   繁体   English

iPhone:从图像创建视频

[英]iPhone:Create video from images

I am trying to create video from png images which has no audio file. 我正在尝试从没有音频文件的png图像创建视频。

I have implemented following code but my images are not running smoothly. 我已经实现了以下代码,但我的图像运行不顺畅。

- (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];
    }

}

If you have any idea plz share it. 如果你有任何想法,请分享它。 thanx in advance. 提前。

You can have a look on this topic 您可以查看此主题

Make movie file with picture Array and song file, using AVAsset 使用AVAsset制作带有图片阵列和歌曲文件的电影文件

It will be a bit confusing if you haven't try AVFoundation before. 如果您之前没有尝试过AVFoundation,那将会有点混乱。

It's concept is like: 它的概念如下:
1. Set up a assetwriter (helper for writing the video out). 1.设置资产编写者(用于写出视频的帮助者)。
2. Tell the writer what track you wanna input (adding the video and audio writerInput) 2.告诉作者您想要输入的曲目(添加视频和音频writerInput)
3. If everything is okay, try to put your image to the video track 3.如果一切正常,请尝试将图像放到视频轨道上
4. Ask the writer to encode. 4.要求作者编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM