player.rate = 4.0
对我不起作用。
使用AVPlayer
获得4.0的速度是一种好方法,还是有更好的方法?
答案 0 :(得分: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];