我想实现慢动作视频像Slo-Mo相机的Defalut功能,我使用下面的代码,它适用于视频.
但在音频轨道中该视频无法正常工作. @H_502_3@double videoScaleFactor =8.0; compositionAudioTrack scaleTimeRange:CMTimeRangeMake(kCMTimeZero,videoDuration) toDuration:CMTimeMake(videoDuration.value* videoScaleFactor,videoDuration.timescale)]; [compositionVideoTrack scaleTimeRange:CMTimeRangeMake(kCMTimeZero,videoDuration) toDuration:CMTimeMake(videoDuration.value* videoScaleFactor,videoDuration.timescale)]; this scenario is woking properly for video slowmotion.But in audio slow-motion it is not working...
但在音频轨道中该视频无法正常工作. @H_502_3@double videoScaleFactor =8.0; compositionAudioTrack scaleTimeRange:CMTimeRangeMake(kCMTimeZero,videoDuration) toDuration:CMTimeMake(videoDuration.value* videoScaleFactor,videoDuration.timescale)]; [compositionVideoTrack scaleTimeRange:CMTimeRangeMake(kCMTimeZero,videoDuration) toDuration:CMTimeMake(videoDuration.value* videoScaleFactor,videoDuration.timescale)]; this scenario is woking properly for video slowmotion.But in audio slow-motion it is not working...
请帮我..
解决方法
我找到了Audio SlowMotion的解决方案
double videoScaleFactor = 8.0;
[compositionAudioTrack scaleTimeRange:CMTimeRangeMake(kCMTimeZero,videoDuration)
toDuration:CMTimeMake(videoDuration.value * videoScaleFactor,videoDuration.timescale)];
它工作正常但不能在AVPlayer中工作
所以为此你必须设置AVPlayerItem的以下属性
AVPlayerItem * playerItem = nil;
playerItem.audioTimePitchAlgorithm = AVAudioTimePitchAlgorithmVarispeed;