Reputation: 396
I have an application requirement where user can trim the video of any size with specified time frame. For example if there is a video of say 20 seconds , user can select from any second to any second (eg : 5 to 15). For this I need to display the time frame for the video, default video trimming using UIImagePicker and enabling allowsEditing property to YES doesn't show the time from where to where it is cut. Simply the requirement is like whats app video trimming, with display of time frames of video and trimming. Hoe can I achieve these goals? Any help is highly appreciated. Thanks in advance.
Upvotes: 3
Views: 1255
Reputation: 17535
Yes, You can extract video from start to end duration.
You can do using like this and you get our more demo on github for video extration.
CMTime duration = Your time duration ;
AVMutableCompositionTrack *videoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo
preferredTrackID:kCMPersistentTrackID_Invalid];
[videoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, duration)
ofTrack:videoAsset3Track
atTime:kCMTimeZero error:&error];
Upvotes: 1