我想将视频导出3次以上原创(同一视频重复3次)。这意味着2秒的视频将是6秒。那怎么可能呢?
我已经实现了导出视频并将其保存在cameraroll中。 所以请告诉我最好的方法是什么。
答案 0 :(得分:0)
AVMutableCompositionTrack *compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
/*******************Code for increase video length*****************************************/
AVAssetTrack *clipVideoTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
[compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration) ofTrack:clipVideoTrack atTime:kCMTimeZero error:nil];
CMTime videoLength = videoAsset.duration;
if(self.isVideo){
[compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration) ofTrack:clipVideoTrack atTime:videoAsset.duration error:nil];
videoLength = CMTimeAdd(videoAsset.duration, videoAsset.duration);
}
[compositionVideoTrack setPreferredTransform:[[[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] preferredTransform]];
//slow down whole video by 2.0
double videoScaleFactor = scalfactor;
CMTime videoDuration = videoLength;
[compositionVideoTrack scaleTimeRange:CMTimeRangeMake(kCMTimeZero, videoDuration)
toDuration:CMTimeMake(videoDuration.value/videoScaleFactor, videoDuration.timescale)];
CGSize videoSize = [clipVideoTrack naturalSize];
/******************* End Code *************************************************************/