I want to trim a video file. I want to just pick the video from a gallery and convert it to a 15-second video. If I use normal trimming with picker view controller, it does
The above answer worked for me with a little change in case we need to set both start time and end time to trim.
I changed this:
CMTime start = CMTimeMakeWithSeconds(1.0, 600); // you will modify time range here
CMTime duration = CMTimeMakeWithSeconds(15.0, 600);
CMTimeRange range = CMTimeRangeMake(start, duration);
To this:
CMTime start = CMTimeMakeWithSeconds(self.StartTime, 600); // you will modify time range here
CMTime duration = CMTimeSubtract(CMTimeMakeWithSeconds(self.EndTime, 600), start);
CMTimeRange range = CMTimeRangeMake(start, duration);
It worked for me.