2015-10-15 78 views
0

我想導出視頻3倍以上原始(相同的視頻重複3次)。這意味着2秒的視頻將是6秒。那麼這怎麼可能?如何將視頻長度設置爲原來的3/4倍?

我已經實現了導出視頻並將其保存在相機中。 所以請告訴我這是做什麼最好的方法。

+0

重複視頻3次...爲什麼要製作視頻或大尺寸? –

+0

因爲我想分享它在wat的應用程序,所以它會看起來不錯。 2秒的視頻沒有意義。 –

回答

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 *************************************************************/ 
相關問題