Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Video capture with 1:1 aspect ratio in iOS

I want to capture videos with an iOS camera with 1:1 aspect ratio.

I tried with UIImagePickerController, but it doesn't provide changing aspect ratio. Could anyone give me ideas?

Additionally, the iPhone app "Viddy" provides 1:1 aspect ratio video capturing:

Viddy app

like image 330
ksh Avatar asked Jan 13 '23 19:01

ksh


1 Answers

 GPUImageMovie* movieFile = [[GPUImageMovie alloc] initWithAsset:asset];
    GPUImageCropFilter *cropFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CGRectMake(0.0, 0.1, 1.0, 0.8)];

    [movieFile addTarget:cropFilter];
    GPUImageMovieWriter* movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(320.0, 320.0)];

    [cropFilter addTarget:movieWriter];
    [movieWriter startRecording];
    [movieFile startProcessing]; 
    [movieWriter finishRecordingWithCompletionHandler:^{

               NSLog(@"Completed Successfully");
               [cropFilter removeTarget:movieWriter];
               [movieFile removeTarget:cropFilter];
    }];

where

  • asset is the input movie file.
  • cropRegion is the area to crop.
  • movieUrl is the target url to save the cropped movie.
like image 94
arunit21 Avatar answered Jan 21 '23 22:01

arunit21