Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending an AVMutableComposition

I would like to render some graphics to the end of my AVMutableComposition, like credits at the end of a movie. How can I create a blank asset that would extend the composition time to give me some blank space I can render to?

like image 480
rob Avatar asked Nov 28 '25 23:11

rob


1 Answers

I found the answer. It lies in the insertEmptyTimeRange method. An example:

//comp is an AVMutableComposition

float secondsToExtend = 5.0f;
long long timescale = comp.duration.timescale;
CMTime endTime = CMTimeMake(comp.duration.value - 1, timescale);
CMTime extendDuration = CMTimeMake(secondsToExtend * timescale, timescale);
CMTimeRange emptyTimeRange = CMTimeRangeMake(endTime, extendDuration);
[comp insertEmptyTimeRange:emptyTimeRange];
like image 166
rob Avatar answered Dec 02 '25 03:12

rob