2015-06-10 77 views

回答

2

使用[AVComposition scaleTimeRange:toDuration:]來產生快動作AVAsset

float rate = 4.0; 
AVAsset *asset = [AVAsset assetWithURL:someURL]; 
AVMutableComposition *composition = [AVMutableComposition composition]; 
NSError *error = nil; 
[composition insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset.duration) 
        ofAsset:asset 
         atTime:kCMTimeZero error:&error]; 
[composition scaleTimeRange:CMTimeRangeMake(kCMTimeZero, asset.duration) 
       toDuration:CMTimeMultiplyByFloat64(asset.duration, 1/rate)]; 
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:composition]; 
AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem]; 
+0

嘿!你有沒有想過如何在飛行中更新這個作文?我應該刪除timeRange並且再次縮放它嗎?並將其應用於新的組合? –