iOSPawan
iOSPawan

Reputation: 2894

trimming video using AVMutableComposition

To trim video I have used removeTimeRange method of AVMutableCompositionTrack.

[mCachedCompositionTrack removeTimeRange:CMTimeRangeMake(CMTimeMake(3, NSEC_PER_SEC), CMTimeMake(4, NSEC_PER_SEC))];

Here video length is 10 sec. and after calling above method video length should be 9sec (frames with timeRange 3 - 4 should be removed from track). But it is not happening instead it always returns actual video length with blank frames.

Any help will be appriciated.

Upvotes: 2

Views: 1632

Answers (1)

fisk
fisk

Reputation: 191

I believe you are using the CMTimeMake function incorrectly but it is hard to tell with so little code. CMTimeMake creates a fraction of time. This should correspond to the number of frames per second. So if you want, in this case, to cut off one second. But it might be important to consider what the frame rate is as well.

If the frame rate was 30 frames per second, I would create the time interval the following way: CMTimeRangeMake(CMTimeMake(3*30, 30), CMTimeMake(4*30, 30))

Have you tried this?

Upvotes: 2

Related Questions