8

i want to implement Slowmotion Video like Defalut functionality of Slo-Mo in Camera and i used following code and it worked fine for video. but in Audio track of that video is not working properly.

   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...

Please help me..

Developer
  • 760
  • 3
  • 15
  • First of All thanks, i am also try this feature, By Using MpmoviePlayerController to play video in slow motion but not got success please help me provide some code for that feature. – Dinesh Patel Apr 03 '15 at 09:35

1 Answers1

7

i found solution of Audio SlowMotion

double videoScaleFactor =8.0;

[compositionAudioTrack scaleTimeRange:CMTimeRangeMake(kCMTimeZero, videoDuration) toDuration:CMTimeMake(videoDuration.value* videoScaleFactor,videoDuration.timescale)];

its working properly but not working in AVPlayer so for that you have to set following property of AVPlayerItem

AVPlayerItem *playerItem = nil;

playerItem.audioTimePitchAlgorithm = AVAudioTimePitchAlgorithmVarispeed;

Developer
  • 760
  • 3
  • 15