0

I had done for merging array of images to video.....Can anyone help me to make a movie using array of images and video. Here I added the code for making array of image to 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 Answers0