结合图像和视频制作完整的电影

时间:2016-05-09 06:10:20

标签: ios arrays image video

我已经完成了将图像数组合并到视频中......任何人都可以帮助我使用图像和视频阵列制作电影。 在这里,我添加了将图像数组制作成视频的代码

NSError *error = nil;
NSFileManager *fileMgr = [NSFileManager defaultManager];
NSString *documentsDirectory = [NSHomeDirectory()
 stringByAppendingPathComponent:@"Documents"];
NSString *videoOutputPath = [documentsDirectory stringByAppendingPathComponent:@"Montage-Videos.mp4"];
if ([fileMgr fileExistsAtPath:videoOutputPath])
    [fileMgr removeItemAtPath:videoOutputPath error:&error];
 {
     UIImage * img;
     imageArray = [[NSMutableArray alloc]init];
     videoURLArray = [[NSMutableArray alloc]init];
    for (int i=0; i<[randomArray count]; i++) {
         AVAsset *asset = [AVAsset assetWithURL:[randomArray objectAtIndex:i]];
        if ([[randomArray objectAtIndex:i] isKindOfClass:[NSURL class]]) {

            // Here I need to add video to the array for making video.
        }
        else{

            img = [randomArray objectAtIndex:i];
            [imageArray addObject:img];

        }
    }

    UIImage *image ;

    for (int i=0; i<[imageArray count]; i++) {
        image = [imageArray objectAtIndex:0];
    }
    if ([imageArray count]>0) {

        dispatch_queue_t queue = dispatch_queue_create("com.example.MyQueue", DISPATCH_QUEUE_SERIAL);
        dispatch_sync(queue, ^{
            [self writeImagesToMovieAtPath:videoOutputPath withSize:CGSizeMake(374, 456) withImage:image];
        });
    }
 }
}

0 个答案:

没有答案