1

I have one recorded video and i want to save it as a new video with 1.5 playback speed(fast-forward) in ios sdk . Can anyone please suggest how can i achieve this functionality?

Thanks Yashesh

Yashesh
  • 1,799
  • 1
  • 11
  • 29
  • @Michel nope.but if u get any reference or example then please share it with me. – Yashesh Aug 13 '14 at 05:49
  • i am going to do a project where this needs to be done. it will probably be a slow process but the only thing i can imagine right now is going from frame to frame in the original (translate each frame to a keyframe) and leave some frames out in the duplicate. but that can't be right, i guess. i need to give it more thought before i start coding anything. it seems not so easy since this is not available in open source video kits or even in commercial ones. –  Aug 13 '14 at 18:12
  • hmmmm. If u get access of the keyframe then you can set some seconds to each keyframe, may be that will help you. – Yashesh Aug 14 '14 at 07:37

2 Answers2

5
AVURLAsset* videoAsset = nil; //self.inputAsset;

//create mutable composition
AVMutableComposition *mixComposition = [AVMutableComposition composition];

AVMutableCompositionTrack *compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo
                                                                               preferredTrackID:kCMPersistentTrackID_Invalid];
NSError *videoInsertError = nil;
BOOL videoInsertResult = [compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration)
                                                        ofTrack:[[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]
                                                         atTime:kCMTimeZero
                                                          error:&videoInsertError];
if (!videoInsertResult || nil != videoInsertError) {
    //handle error
    return;
}

//slow down whole video by 2.0
double videoScaleFactor = 2.0;
CMTime videoDuration = videoAsset.duration;

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

//export
AVAssetExportSession* assetExport = [[AVAssetExportSession alloc] initWithAsset:mixComposition
                                                                     presetName:AVAssetExportPresetLowQuality];
falcon143
  • 702
  • 4
  • 19
-1

Check this

NSBundle *bundle = [NSBundle mainBundle];
    NSString *moviePath = [bundle pathForResource:titleOfButton ofType:@"mov"];
    NSURL *movieURL = [ NSURL fileURLWithPath:moviePath];

    MPMoviePlayerController *themovie = [[MPMoviePlayerController alloc]initWithContentURL: movieURL];  
    [themovie play];
    [themovie setCurrentPlaybackRate:2.f];
falcon143
  • 702
  • 4
  • 19
  • Above code will play video with 2.0 playback rate, i want to save that video with 2.0 playback rate. how can i do that ? – Yashesh Jul 15 '14 at 07:43
  • I am getting vedio from photo gallery ..and took some range of buttons given range like 2x ,-2x ,4x ,-4x ..i can playing vedio with this all ranges of vedios but my requirement is if i select -2x range and click done button will get only -2x range of vedio only..it means i want to save it and get from that ..how can i do like that ..please any body reply me ..i have been searching from manydays – vani lucky Mar 27 '15 at 07:10